Skip to content

Instantly share code, notes, and snippets.

@dezintegro
dezintegro / server.conf
Created August 1, 2022 21:02 — forked from iliakan/server.conf
Nginx configuration for separated frontend and backend endpoints
upstream example-webpack {
server 127.0.0.1:8080;
}
upstream example-backend {
server 127.0.0.1:3000;
}
server {
listen 80;
@dezintegro
dezintegro / pre-commit-fix.sh
Created April 26, 2021 18:47
PyCharm pre-commit workaround
#!/bin/bash
pre-commit install
mv .git/hooks/pre-commit .git/hooks/pre-commit-python
cat <<EOF > .git/hooks/pre-commit
#!/bin/bash
source ${VIRTUAL_ENV}/bin/activate
DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
python \${DIR}/pre-commit-python
def jsonrpc_registry(cls):
cls.methods = jsonrpcserver.methods.Methods()
for methodname in dir(cls):
method = getattr(cls, methodname)
if hasattr(method, '_rpc'):
cls.methods.add(method)
return cls
@dezintegro
dezintegro / .bachrc
Last active August 9, 2018 19:50
Aliases for .bashrc
# Remove local git branches which no longer on remote
git_clean() {
git branch -vv | grep -E ': пропал]|: gone]' | awk '{print $1}' | xargs git branch -d
}
# Wrapper on git flow feature start
feature_start() {
b=${@:2}
git flow feature start "#$1_${b// /_}"
}
from rest_framework import serializers
from models.house import House
from models.house_user import HouseUser
from workdays.serializers import WorkdaysSerializer
class TimezoneField(serializers.ChoiceField):
def to_representation(self, value):
return str(value)
@dezintegro
dezintegro / clean-docker
Last active July 17, 2018 11:58 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
1. Kill all running containers
docker kill `docker ps -q`
2. Delete all containers
$ docker ps -q -a | xargs docker rm
-q prints only the container IDs
-a prints all containers
from machine import Pin,Timer,PWM
pwm = PWM(Pin(14),100)
polar = 0
duty = 0
def setLed(t):
@dezintegro
dezintegro / app.js
Created March 16, 2016 19:50 — forked from rnkoaa/app.js
A simple angularjs with angular-ui modal form which includes validation on the client side. Thanks http://scotch.io/tutorials/javascript/angularjs-form-validation
var app = angular.module("modalFormApp", ['ui.bootstrap']);
app.controller("modalAccountFormController", ['$scope', '$modal', '$log',
function ($scope, $modal, $log) {
$scope.showForm = function () {
$scope.message = "Show Form Button Clicked";
console.log($scope.message);
var modalInstance = $modal.open({
@dezintegro
dezintegro / Delete_spaces.txt
Last active March 15, 2016 13:57
Delete spaces from string
var Text = ' a s d f ';
var cleaned = Text.replace(/\s+/g, '');