Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View grimen's full-sized avatar

Jonas Grimfelt grimen

View GitHub Profile
@sabderemane
sabderemane / workflow_full_v2.yml
Last active November 9, 2022 04:23
Full workflow of python with docker services (postgres), to run django tests
name: Test Workflow
on: push
jobs:
test:
runs-on: ubuntu-latest
services:
image: postgres
@grimen
grimen / generators-test.js
Last active January 23, 2019 09:41
Experiments with Node.js Generator API - partially requires Node 10.
/* =========================================
IMPORTS
-------------------------------------- */
const fs = require('fs')
const { promisify } = require('util')
sleep = promisify(setTimeout)
@grimen
grimen / streams-test.js
Last active January 23, 2019 09:41
Experiments with Node.js Stream API.
/* =============================================
Dependencies
------------------------------------------ */
const debug = require('debug')
const chalk = require('chalk')
const { Readable, Writable, Transform, pipeline } = require('stream')
@eddieantonio
eddieantonio / example.py
Created March 30, 2017 20:43
Zero-dependency Python 3 and Node IPC using UNIX sockets
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import socket
import json
server_address = '/tmp/example.sock'
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(server_address)
@absent1706
absent1706 / sqlalchemy-truncate_db.py
Last active April 5, 2023 03:50
Sqlalchemy: Truncate all tables
def truncate_db(engine):
# delete all table data (but keep tables)
# we do cleanup before test 'cause if previous test errored,
# DB can contain dust
meta = MetaData(bind=engine, reflect=True)
con = engine.connect()
trans = con.begin()
con.execute('SET FOREIGN_KEY_CHECKS = 0;')
for table in meta.sorted_tables:
con.execute(table.delete())
@darkwave
darkwave / proxy.py
Created March 12, 2016 22:42
Python proxy server to redirect calls from localhost to different address (change forward_to variable)
#!/usr/bin/python
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don't Care) license
import socket
import select
import time
import sys
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@katowulf
katowulf / diffList.js
Last active July 28, 2016 18:42
Diff services for monitoring objects and arrays, and creating changelists in Angular.js
/**
* A diff utility that compares arrays and returns a list of added, removed, and updated items
*
* Returns an object with two methods:
* diff: do a one-time diff of two arrays
* watch: observe a variable on scope and report any changes to a callback
*
* Invoking the factory is done like so:
* <code>
* function(listDiff) {
@paulirish
paulirish / gist:5558557
Last active April 18, 2024 14:32
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa