Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
thinkingserious / fluent.py
Created March 5, 2016 02:44
Fluent Interface in Python Using Method Chaining and Reflection
class Fluent:
def __init__(self, cache=None):
self._cache = cache or []
# Build the cache, and handle special cases
def _(self, name):
# Enables method chaining
return Fluent(self._cache+[name])
# Final method call
@siddMahen
siddMahen / prim.py
Created January 4, 2014 22:03
Prim's algorithm, in Python.
from sys import argv
import re
# open the file and get read to read data
file = open(argv[1], "r");
p = re.compile("\d+");
# initialize the graph
vertices, edges = map(int, p.findall(file.readline()))
graph = [[0]*vertices for _ in range(vertices)]
@eliangcs
eliangcs / http-prompt-story.md
Last active June 3, 2020 06:49
How I created HTTP Prompt and got 5000+ stars on GitHub

How I Created HTTP Prompt and Got 5000+ Stars on GitHub

Two months ago, I published an open source project, which went viral by gaining 1200+ stars in the first 24 hours. As of this writing, it has attracted 5000+ stars. The project is called HTTP Prompt:

https://github.com/eliangcs/http-prompt

Here I want to share its development story.

It all began with Vertica. Not long ago, I used Vertica every day for my work. Vertica is a powerful database, but the official client (vsql) is not powerful at all. The GUI alternative, DbVisualizer, is bad as well.

@philcryer
philcryer / gitrc
Last active May 5, 2020 00:00
This .gitrc activates when you're in a directory that is a git repo. It tells you the branch you're on, with color handling of the bash prompt according to the branch/status. For example, the prompt would look like this: [~/foo](master) $ with (master) colored GREEN, until you've added a file to the repo, but not committed it, then it will turn …
#!/bin/bash
#
# Set your bash prompt according to the branch/status of the current git repository.
#
# One-line install:
# curl https://gist.github.com/philcryer/5066010/raw/784e1e4c9df5289fe6f922fb6d122461d374758c/gitrc -o ~/.gitrc; echo "source ~/.gitrc" >> ~/.profile; source ~/.profile
#
# Originally forked from http://gist.github.com/31934 then modified liberally.
#
var dom = Bloop.dom;
var Box = Bloop.createClass({
getInitialState: function() {
return { number: 0 };
},
updateNumber: function() {
this.state.number++;
},
@mystix
mystix / fix-city-country-stripAlpha-function.sql
Last active December 1, 2019 13:39
Magento - Customer address-related SQL (note: these queries only work on MySQL databases)
DROP FUNCTION IF EXISTS stripAlpha;
-- taken from http://stackoverflow.com/a/5146376
delimiter //
create function stripAlpha(str varchar(50)) returns varchar(50)
no sql
begin
declare verification varchar(50);
declare result varchar(50) default '';
@iodic
iodic / list-changes-between-branches.sh
Created March 28, 2018 09:17
Show a list of commit differences between git branches
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative master..develop
@Filirom1
Filirom1 / cri.md
Created December 5, 2017 13:31
CRI-O and CRI-Containerd

Install Golang

On a fresh CentOS 7.4, as root:

yum install -y golang git wget
@Tomfox91
Tomfox91 / brConv.d
Created August 14, 2014 19:59
Converter for .BR3, .BR4, .BR5 files produced by BMW music backups. Simply negates all bites. See http://www.1erforum.de/hifi-navi/konvertieren-von-br4-br5-mp3-22678.html.
import std.file;
int main(char[][] args) {
if (args.length != 2) return 101;
auto filename = args[1];
auto basename = filename[0 .. $-4];
auto extension = filename[$-3 .. $];
if (!exists(filename)) return 102;
from sentry.conf.server import *
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
'default': {
# You can swap out the engine for MySQL easily by changing this value
# to ``django.db.backends.mysql`` or to PostgreSQL with
# ``django.db.backends.postgresql_psycopg2``