Skip to content

Instantly share code, notes, and snippets.

Philipp Otto philippotto

  • Berlin
View GitHub Profile
@unpoetic-circle
unpoetic-circle / Tab Context.sublime-menu
Last active Nov 22, 2019
Sublime Text 3 Plugin: Close all saved tabs
View Tab Context.sublime-menu
[
{ "caption": "-" },
{ "command": "close_saved", "caption": "Close Saved Files" }
]
@matttti
matttti / effect-generators.js
Created Jan 28, 2017
[redux-saga]: flow-typing of yield return values
View effect-generators.js
import * as IOEffects from 'redux-saga/effects'
export function * select (...args) {
return yield IOEffects.select(...args)
}
export function * put (...args) {
return yield IOEffects.put(...args)
}
@nphyx
nphyx / test-DataView_Uint42Accessors.js
Created Sep 14, 2015
Unit test for unsigned 24-bit int accessors for Javascript DataViews.
View test-DataView_Uint42Accessors.js
describe("DataView", function() {
it("should implement Uint24 accessors", function() {
var i, n, buf, dv;
buf = new ArrayBuffer(3);
dv = new DataView(buf);
n = Math.pow(2, 24);
// this should give us decent coverage without trying every single number, which takes forever
for(i = 1; i < n; i += 111) {
dv.setUint24(0, i);
dv.getUint24(0).should.equal(i);
@chrismdp
chrismdp / s3.sh
Last active Jul 2, 2020
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
View s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@yuanqing
yuanqing / gist:87bceacedde4dbd96fab
Last active Jun 22, 2020
Sublime Text: Wrap Selection in Backticks
View gist:87bceacedde4dbd96fab
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
}
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active Jul 9, 2020
how to delete a git tag locally and remote
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@firstdoit
firstdoit / compress-pdf-with-gs.md
Created Aug 30, 2013
Compress PDF files with ghostscript
View compress-pdf-with-gs.md

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@thomassuckow
thomassuckow / karma.js
Last active Jun 18, 2017
Using karma to load requirejs tests with the .spec.js suffix. Note the base url needs the / otherwise karma-requirejs will whine about no timestamp (paths will differ) We mangle the files list to be relative, otherwise using relative paths in the form of "./bar" will fail. In my use case I have a shared config.js file that has more configuration…
View karma.js
var tests = Object.keys(window.__karma__.files).filter(function (file) {
return /\.spec\.js$/.test(file);
}).map(function(file){
return file.replace(/^\/base\/src\/js\/|\.js$/g,'');
});
require.config({
baseUrl: '/base/src/js',
paths: {
"lib":"../../target/js/lib"
@matthiasg
matthiasg / docs style (bootstrap)
Created Aug 5, 2013
the callouts from the bootstrap documentation
View docs style (bootstrap)
/* Side notes for calling out things
-------------------------------------------------- */
/* Base styles (regardless of theme) */
.bs-callout {
margin: 20px 0;
padding: 15px 30px 15px 15px;
border-left: 5px solid #eee;
@amitchhajer
amitchhajer / Count Code lines
Created Jan 5, 2013
Count number of code lines in git repository per user
View Count Code lines
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
You can’t perform that action at this time.