Skip to content

Instantly share code, notes, and snippets.

var active = false;
function changeRefer(details) {
if (!active) return;
for (var i = 0; i < details.requestHeaders.length; ++i) {
if (details.requestHeaders[i].name === 'Referer') {
details.requestHeaders[i].value = 'http://www.google.com/';
break;
}
@florianbeer
florianbeer / set-tmux-title
Created April 21, 2015 10:47
Set tmux pane title to short hostname on ssh connections
ssh() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then
tmux rename-window "$(echo $* | cut -d . -f 1)"
command ssh "$@"
tmux set-window-option automatic-rename "on" 1>/dev/null
else
command ssh "$@"
fi
}
moved to github --> https://github.com/bill-auger/git-branch-status/
@EmmanuelOga
EmmanuelOga / IterateCodepoints.java
Last active September 16, 2021 22:34
Iterating over the "letters" (codepoints, not chars) of a string.
package com.emmanueloga.cracking.arrays;
import java.util.Iterator;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
class StringCodepointsIterable implements Iterable<String> {
public class StringCodepointsIterator implements Iterator<String> {
private int index = 0;
# Copyright (c) Microsoft Corporation. All rights reserved.
"""Authorization helper functions.
"""
from hashlib import sha256
import hmac
import pydocumentdb.http_constants as http_constants
@wmealing
wmealing / C-states.md
Last active May 17, 2024 07:53
What are CPU "C-states" and how to disable them if needed?

To limit a CPU to a certain C-state, you can pass the processor.max_cstate=X option in the kernel line of /boot/grub/grub.conf.

Here we limit the system to only C-State 1:

    kernel /vmlinuz-2.6.18-371.1.2.el5 ... processor.max_cstate=1

On some systems, the kernel can override the BIOS setting, and the parameter intel_idle.max_cstate=0 may be required to ensure sleep states are not entered:

@edwinb
edwinb / divide.idr
Created July 2, 2014 09:44
Type safe division
module Main
{- Divide x by y, as long as there is a proof that y is non-zero. The
'auto' keyword on the 'p' argument means that when safe_div is called,
Idris will search for a proof. Either y will be statically known, in
which case this is easy, otherwise there must be a proof in the context.
'so : Bool -> Type' is a predicate on booleans which only holds if the
boolean is true. Essentially, we are making it a requirement in the type
that a necessary dynamic type is done before we call the function -}
@staltz
staltz / introrx.md
Last active June 3, 2024 11:21
The introduction to Reactive Programming you've been missing
import System.Directory
import System.Environment
import System.FilePath
import Control.Applicative ((<$>))
import Control.Arrow (first, second)
import Control.Monad (void)
import Data.Either (rights)
import Data.List (isSuffixOf)
import Data.Set (Set, (\\), empty, fromList, insert, singleton, toList, union)
import Text.Parsec
@clarkdave
clarkdave / logstash-sentry.rb
Last active May 15, 2023 11:34
(Logstash) Sentry output plugin
# The MIT License (MIT)
# Copyright (c) 2014 Dave Clark
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: