Skip to content

Instantly share code, notes, and snippets.

View rsarai's full-sized avatar
🏜️

Rebeca Sarai rsarai

🏜️
View GitHub Profile
@jboner
jboner / latency.txt
Last active June 29, 2024 19:54
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
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 29, 2024 08:12
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@egarson
egarson / greek-letters-abbrevs.el
Created June 17, 2013 20:52
Emacs abbrev table for Greek lower- and upper-case letters. See abbrev-mode for more.
(define-abbrev-table 'greek-abbrev-table
'(
;; Greek small letters
("8al" "α")
("8be" "β")
("8ga" "γ")
("8de" "δ")
("8ep" "ε")
("8ze" "ζ")
("8et" "η")
@martinus
martinus / DifferentialEvolution.cpp
Created September 22, 2014 07:53
Differential Evolution - Sample Code
/* Example adapted from http://www.drdobbs.com/database/differential-evolution/184410166
*
* This implements the DE/rand/1/bin optimization algorithm.
*
*/
/* Initialize individuals */
for (i=0; i<NP; i++) {
/* randomly initialize all individuals */
for (j=0; j<D; j++) {
import sys
import h5py
def main():
data = read()
if sys.argv[1] == 'x':
x_slice(data)
elif sys.argv[1] == 'z':
z_slice(data)
@Jacketbg
Jacketbg / fetch_inoreader_starred_articles
Created April 27, 2015 12:46
Fetch your Inoreader starred articles
<?php
/*
This script exports user's starred articles via the official Inoreader API.
Use it in case you have thousands of starred articles since Inoreader's export function will not export much more than 1000 articles.
Use your Inoreader email and password to sign in.
You will need to create a developer application first to obtain $app_id and $app_key. Read here about this - http://www.inoreader.com/developers/register-app
*/
$email = ""; // You Inoreader username or email
$password = ""; // Your Inoreader password
@ErisDS
ErisDS / examples.md
Last active May 2, 2024 08:23
Ghost Filter Query examples

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

#!/usr/bin/env python
import hashlib
import hmac
import time
import requests
import datetime
# Q. Do you have A Websocket API?
# A. Yes, and we strongly recommend you to use it. Please, check our JavaScript websocket implementation for our WebSocket API here:
# https://github.com/blinktrade/frontend/blob/master/jsdev/bitex/api/bitex.js
@mariocesar
mariocesar / admin.py
Last active December 28, 2023 19:17
Django admin decorator to create a confirmation form action, like the default delete action works
from .models import Post, Category
from .decorators import action_form
class PostCategoryForm(forms.Form):
title = 'Update category for the selected posts'
myfile = forms.FileField()
category = forms.ModelChoiceField(queryset=Category.objects.all())