Skip to content

Instantly share code, notes, and snippets.

View toshsan's full-sized avatar
🌴
On vacation

Santosh Sahoo toshsan

🌴
On vacation
View GitHub Profile
@toshsan
toshsan / hype.jsx
Last active September 16, 2018 18:07
An experimental virtual dom/jsx renderer.
/** @jsx hype */
function render(root, el) {
while (root.lastChild) {
root.removeChild(root.lastChild);
}
root.appendChild(el);
}
function hype(name, attributes, ...children) {
@rgbkrk
rgbkrk / sql-mixin.md
Last active December 20, 2024 05:36
Turning lodash into declarative SQL

Lodash has a sweet feature called a mixin that lets you alias function names. Below here I alias names that we're used to using in SQL to (roughly) equivalent functions in lodash.

_.mixin({
  select: _.map,
  from: _.chain,
  where: _.filter,
  groupBy: _.sortByOrder,
})
@n-johnson
n-johnson / latency.txt
Created November 8, 2015 07:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@n-johnson
n-johnson / cloudfront_ip.sh
Created October 26, 2015 14:13
cloudfront ip enumeration
# req: prips
curl https://ip-ranges.amazonaws.com/ip-ranges.json \
| grep -B 2 CLOUDFRONT \
| grep 'ip_prefix' \
| awk '{ print $2 }' \
| tr -d '",' \
| xargs -I{} prips {}
@n-johnson
n-johnson / dig_any.sh
Last active November 26, 2015 19:18
Replacement for dig -t any since cloudflare now refuses to answer the query with the response: 'Please stop asking for ANY" "See draft-jabley-dnsop-refuse-any"'
_dig() {
local domain=$1;
local type=$2;
dig "$domain" -t "$type" \
| sed -n '/;; ANSWER SECTION/,/^$/p' \
| sed '1d' \
| sed '/^$/d';
}
@ancymathai
ancymathai / image.php
Created July 14, 2015 16:49
image_comparison_using_php
<?php
$a=$_REQUEST['txt1'];
$b=$_REQUEST['txt2'];
class compareImages
{
private function mimeType($i)
var child_process = require('child_process'),
http = require('http');
url = require('url'),
ffmpeg = null;
var livestream = function (req, resp) {
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var input = 'udp://225.1.1.1:8208';
@pgburt
pgburt / Podcast-Checklist.md
Last active April 13, 2024 22:19
Audacity Podcast Checklist

Recording

  • Set Audacity to use the External mic.
  • Ensure you're recording in 16-bit PCM + 44100Hz.
  • Do a sound check, record everyone in the room speaking. You want the lighter part of the meter bar (the green or red bar at the top) to bounce between -12db and -6db while people are talking. It's hard to achieve this... so just settle for as close as you can get, without the bars going off the scale :)
  • Play it back and tweak levels until it sounds good @ 60% speaker volume.
  • Save the Project BEFORE recording live :D (prevents quality issues)

Edit for Content

  • Join recordings to one track.
  • Listen to it + Edit bad content out.
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@MohamedAlaa
MohamedAlaa / ImageMagick-snippets.md
Last active December 25, 2024 13:50
ImageMagick Snippets

Remove white background color of an image in ImageMagick

$ convert  your.jpg  -transparent white  your.png

Flatten a transparent image with a white background: