Skip to content

Instantly share code, notes, and snippets.

@anaclumos
anaclumos / RH.java
Last active October 25, 2024 09:02
Silicon Valley S06 E04 Richard Hendricks Sorted List Brute Force Search Code
(R. Hendricks 112) int index = 0;
(R. Hendricks 113) while (!element.equals(sortedList.get(index))
(R. Hendricks 114) && sortedList.size() > ++index);
(R. Hendricks 115) return index < sortedList.size() ? index : -1;
@multun
multun / message_json_parser.py
Created December 26, 2018 22:51
Pretty-print a facebook message.json, fixing up broken encoding
import sys
import json
from datetime import datetime
def fixup_str(text):
return text.encode('latin1').decode('utf8')
def fixup_list(l):
@mbrehin
mbrehin / prosemirror.js
Created January 26, 2018 08:59
Prosemirror example: replacing form textareas
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import {
defaultMarkdownParser,
defaultMarkdownSerializer,
schema,
} from 'prosemirror-markdown'
import { exampleSetup } from 'prosemirror-example-setup'
import 'prosemirror-view/style/prosemirror.css'
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 25, 2025 09:20
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@petrbel
petrbel / .travis.yml
Last active October 26, 2019 10:29 — forked from iedemam/gist:9830045
Travis-CI submodules
# Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior!
# disable the default submodule logic
git:
submodules: false
# use sed to replace the SSH URL with the public URL, then init and update submodules
before_install:
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
@Ajnasz
Ajnasz / noemoji.pl
Created October 14, 2014 11:53
# Replace annoying emojis. You can see them on slack, for example.
# noemoji.pl
#
# Replace annoying emojis. You can see them on slack, for example.
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '1.0';
@alikins
alikins / .gitattributes
Created October 7, 2014 14:02
po/pot file attributes for textconf and diff (ie, make git diff on gettext files less useless)
*.pot diff=msgcat
*.po diff=msgcat
@apk
apk / websock.sh
Created April 18, 2012 15:51
A web socket server as a bash script.
#!/bin/bash
# WebSocket shell, start & browse to http://<Host>:6655/
# Requires bash 4.x, openssl.
# Author: [email protected] (which isn't me, apk)
coproc d { nc -l -p 6656 -q 0; }
nc -l -p 6655 -q 1 > /dev/null <<-ENDOFPAGE
HTTP/1.1 200 OK
<html><head><script language="javascript">
var url = location.hostname + ':' + (parseInt(location.port) + 1);
@febuiles
febuiles / songs.md
Last active July 1, 2022 03:45
Fetching lyrics in Unix

Fetching lyrics in the command line

Objective: Print the lyrics for the current playing song.

How: We'll create a small bash script to do the fetching for us (using curl) and then we'll display it either in the terminal or in our $EDITOR

Get the current song

First we'll need to get the name of the current song and its artist:

@apk
apk / do-cvs-fetch
Created April 14, 2010 06:55
Import cvs tree into git repo
#!/bin/sh
# Arg: path/to/module/in/cvs
# Run git-cvsimport and place result in subdir cvs.path.to.module.in.cvs
# or update git repo there if already existing (incremental fetch should work)
# Fix to your cvs credentials
p="$1"
d="cvs.`echo $p | tr / .`"
test -d "$d" || mkdir "$d"
cd "$d" || exit 1
git cvsimport -p x -v -k -a -d :pserver:me@cvshost:/opt/cvs "$p"