Skip to content

Instantly share code, notes, and snippets.

@sidcha
sidcha / split-patch.pl
Created April 21, 2019 09:38
Splits or dissects large patch file into smaller per-file-change patches. Comes in handy when patches don't apply anymore.
#!/bin/perl
while (<>) {
if(/^diff --git a\/(\S+)/) {
close $f if $f;
$s=$1;
$s =~ s:(/|\.):_:g;
$n=sprintf("%03d_%s.patch", ++$i, $s);
open $f, ">", $n;
print $f $_;
# This script will create a cron that downloads the latest image from Himawari 8 every 5 minutes. I use it as my wallpaper.
#
# The Himawari 8 weather satellite acquires 5500x5500 images of Earth every 10 minutes. It captures other weather related
# stills but the full disk, true color is the most amazing.
# The latest is accessible at
# http://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_true_color.jpg.
#
# The satellite was launched in July of 2015. It's the highest resolution
# camera we currently have pointing at earth (stationary at the L1 point).
#
@John2496
John2496 / gist:a2823bd1c04e5d83fa6c
Last active February 6, 2017 16:31
Project managers don't want you to know about this one simple tip...
<?php
// simple technique to remove bugs from your code
// example buggy code
$your_code = "<html><Oh man>i hope i don't have any American cockroaches in my code</Oh man></html>";
$list_of_bugs = array('American cockroach', 'Ants', 'Aphids', 'Aphids', 'Asian paper wasp',
'Asian paper wasp nest', 'Assassin bug', 'Australian bag moth', 'Australian bag moth pupa',
'Avondale spider', 'Backswimmer', 'Bamboo moth', 'Banana moth', 'Banana moth pupa',
var f = function() {
var v = speechSynthesis.getVoices().filter(function(v) { return v.name == 'Hysterical'; })[0],
s = ["ahahahaha", "stop it", "don't tickle me"],
t = new SpeechSynthesisUtterance(s[~~(Math.random()*s.length)]);
t.voice = v; speechSynthesis.speak(t);
};
Array.prototype.slice.call(document.querySelectorAll('a')).forEach(function(a) {
a.addEventListener('mouseover', f);
});
@pdaoust
pdaoust / higher-order-functions.scss
Last active April 5, 2023 11:07
Higher-order functions for Sass 3.3 -- now that we've got the `call()` function in Sass, we can start to compose functions. We don't have the benefit of anonymous functions, of course, but this is real functional programming, folks!
// 'map', 'transform', 'select', or 'project' function. Iterate over a list,
// performing a function on each item, and collecting the new items. Each
// function takes an item as a first argument and returns a transformed item.
// You can pass additional arguments to the function too, which is a decent poor
// man's function composition.
// (I didn't call this f-map because the term 'map' is already used in Sass to
// denote a hash or dictionary.)
@function f-apply($func, $list, $args...) {
$new-list: ();
@each $item in $list {
@iambibhas
iambibhas / scopes.txt
Last active May 22, 2024 14:43
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@trey
trey / reset.sass
Created July 31, 2008 20:36
Eric Meyer's reset.css in Sass. Originally by @postpostmodern.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain) */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,