Skip to content

Instantly share code, notes, and snippets.

View gnud's full-sized avatar

Damjan Dimitrioski gnud

View GitHub Profile
@gnud
gnud / main.c
Created January 18, 2022 12:11
PIR alamr with Arduiono or Arduiono compatible
/*
Melody
Plays a melody upon hitting PIR detection.
circuit:
* 8-ohm speaker on digital pin 8
created 21 Jan 2010
modified 30 Aug 2011
@gnud
gnud / interactive_sequelize.js
Last active May 1, 2021 22:41
Instantiate sequelize via REPL instance for interactive db access and model testing
/*
Usage:
start with:
node --experimental-repl-await interactive_sequelize.js
Then we get the REPL shell
>
> await Product.findAll();
@gnud
gnud / gist:955450145457d03e7e27295b26f4689b
Created April 8, 2021 19:03
collab google extend hack
/**
Call the code in inspector console
*/
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
@gnud
gnud / suicide_app.py
Last active February 27, 2021 00:46
Concept to kill app at certain time for benchmarking
import threading
terminate_app = false
def suicide_callback():
global terminate_app
time_name = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")
print('start', time_name)
from itertools import islice
class MyObject:
def __init__(self, text):
self.text = text
def text(self):
return self.text
default_empty = type('obj', (object,), {'text': ''})
@gnud
gnud / main.py
Last active January 10, 2021 12:01
Documenting dict structure and type validation
from typing import TypedDict, List
class StatsT(TypedDict):
"""
Type that represents the stats
"""
total_sentences: int
total_chars: int
@gnud
gnud / tor service install.txt
Created December 16, 2020 15:22
Powering Python crawling with Tor protection
# Reference:
https://2019.www.torproject.org/docs/debian.html.en
# Add Tor PPA for Ubuntu
```bash
echo '
deb https://deb.torproject.org/torproject.org bionic main \
deb-src https://deb.torproject.org/torproject.org bionic main \
' >> /etc/apt/sources.list.d/tor
@gnud
gnud / range_nodejs.js
Created December 3, 2020 10:08
Node js tricks
const items = Array.from({ length: Number(10) }, (x, i) =>
String(i + 1)
.padStart(5, '0'));
@gnud
gnud / api.py
Created July 7, 2020 06:53
MultiSerializersMixin
class MyViewSet(
lib_mixins.MultiSerializersMixin,
viewsets.ModelViewSet):
queryset = models.MyModel.objects.all()
serializer_class = serializers.DefaultMyModelSerializer
serializer_classes = {
'retrieve': serializers.ItemMyModelSerializer,
'list': serializers.DefaultMyModelSerializer,
'create': serializers.CreateMyModelSerializer,
}
const socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + namespace);
socket.on('connect', function () {
socket.on('some response', function(msg) {
// do something, like change color, add the text somewheres
});
});