Skip to content

Instantly share code, notes, and snippets.

View gunar's full-sized avatar

Gunar Gessner gunar

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@stewartmcgown
stewartmcgown / takeout-discovery.json
Last active April 27, 2024 15:43
Google Takeout API
{
"title": "Takeout API",
"discoveryVersion": "v1",
"ownerName": "Google",
"version_module": true,
"resources": {
"exports": {
"methods": {
"get": {
"flatPath": "v2/{service}/exports/{exportId}",
@nateware
nateware / make_favicon.sh
Last active April 8, 2024 05:48
Imagemagick to create favicon.ico with 16x16 and 32x32 sizes in it
# IE is still braindead so still use favicon.ico
convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 input.png output-16x16.ico
convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 input.png output-32x32.ico
convert output-16x16.ico output-32x32.ico favicon.ico
# Then, HTML needs to specify size="XxY" as largest size due to browser bugs
<link rel="shortcut icon" href="/favicon.ico" sizes="32x32">
@MikeNGarrett
MikeNGarrett / siege
Last active April 3, 2024 03:49
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'
@linhmtran168
linhmtran168 / pre-commit-eslint
Last active February 6, 2024 12:28
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@juanje
juanje / Description.md
Last active November 30, 2023 19:29
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@lukevella
lukevella / elapsed.filter.js
Last active August 15, 2023 02:34
Elapsed Time AngularJS Filter
// {{ dateString | elapsed }}
angular.module('elapsedFilter', [])
.filter('elapsed', function(){
return function(date){
if (!date) return;
var time = Date.parse(date),
timeNow = new Date().getTime(),
difference = timeNow - time,
seconds = Math.floor(difference / 1000),
@tirumaraiselvan
tirumaraiselvan / shim.js
Last active July 31, 2023 17:05
Mount Hasura on Apollo federated gateway
const { ApolloServer } = require("apollo-server");
const gql = require("graphql-tag");
const fetch = require("node-fetch");
const {
introspectionQuery,
buildClientSchema,
printSchema
} = require("graphql");
const typeDefs = gql`
@rjz
rjz / stdin-and-fs-stream.js
Created March 12, 2014 05:18
Streaming from stdin or a file
// Depends on `through`
//
// $ npm install through
//
// Usage:
//
// $ echo 'hello' | node stdin-and-fs-stream.js
// $ echo 'hello' > tmp && node stdin-and-fs-stream.js tmp
//
var fs = require('fs'),
@mikaelz
mikaelz / rtc.lua
Created May 11, 2015 16:07
Awesome WM config for multimedia keys to control Spotify
awful.key({ }, "XF86AudioPlay", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause") end),
awful.key({ }, "XF86AudioNext", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next") end),
awful.key({ }, "XF86AudioPrev", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous") end)