Skip to content

Instantly share code, notes, and snippets.

@clemfromspace
clemfromspace / tasks.py
Created November 24, 2017 04:34
Running a scrapy spider from a celery task
from billiard.context import Process
from scrapy.crawler import Crawler
from scrapy import signals
from scrapy.utils.project import get_project_settings
from twisted.internet import reactor
from celery_app import app
class CrawlerProcess(Process):
@rverton
rverton / test_file_upload.py
Created August 2, 2016 15:00
Test file upload with flask (Python3)
from io import BytesIO
def test_file_upload(client):
data = {
'field': 'value',
'file': (BytesIO(b'FILE CONTENT'), 'test.csv')
}
rv = client.post('/upload', buffered=True,
@Hotell
Hotell / app.component.ts
Last active July 27, 2017 04:07
@ngrx/store integration with ngMetadata/Angular 1
import { Store } from 'ngrx-one/store';
import { INCREMENT, DECREMENT, RESET } from './counter';
interface AppState {
counter: number;
}
@Component({
selector: 'my-app',
template: `
@tracker1
tracker1 / 01-directory-structure.md
Last active July 25, 2024 14:04
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@joelhooks
joelhooks / gear.md
Last active April 2, 2024 20:18
Podcasting Gear List
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}
function unmark {
rm "$MARKPATH/$1"
}
@vikynandha-zz
vikynandha-zz / kutriyaluharam
Last active October 12, 2015 15:57
Regex to match Tamil language 'Kutriyaluharam's
/^(([ஆஈஊஏஐஓஔ])|(.*[க-ஹ][ாீூேைோௌ]))([கசடதபற]ு)$/
@jboner
jboner / latency.txt
Last active July 28, 2024 20:49
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@trey
trey / happy_git_on_osx.md
Last active February 18, 2024 10:46
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@lukaslundgren
lukaslundgren / python27_on_debian.sh
Created May 11, 2012 12:58
How to install python 2.7 on debian
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..