Skip to content

Instantly share code, notes, and snippets.

@trongthanh
trongthanh / gist:2779392
Last active June 25, 2024 08:04
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@ryancdotorg
ryancdotorg / dnaas.c
Created October 30, 2013 23:20
Wrapper library to use /dev/null as a service on Linux via LD_PRELOAD
/* This is a wrapper library that will give your server the power of
* /dev/null as a service, as seen at http://devnull-as-a-service.com/
*
* Compile:
* gcc -ggdb -shared -fPIC dnaas.c -ldl -lcurl -o libdnaas.so
*
* Try:
* LD_PRELOAD=./libdnaas.so dd if=/dev/sda of=/dev/null bs=8192 count=16
*
* Install:
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

import urllib2, re, json, os, time, sys, HTMLParser
html_parser = HTMLParser.HTMLParser()
auth_address = "1KbV1e1u6P6AsY8XNBydgtbtN8iSB5WMyG"
auth_privatekey = "xxxx"
site = "1TaLkFrMwvbNsooF4ioKAY9EuxTBTjipT"
zeronet_dir = ".."
os.chdir(zeronet_dir)
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active May 18, 2024 14:10
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@foonathan
foonathan / borrow.cpp
Last active August 24, 2023 08:42
Quick'n'dirty implementation of Rust's borrow checker for a C++Now Lightning Talk - not supposed to be used
#include <iostream>
#include "borrow_checker.hpp"
int main()
{
auto i = 42;
// borrow `i` under name `ref`
borrow_var(ref, i)
@ErikAugust
ErikAugust / spectre.c
Last active July 5, 2024 18:14
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@purplesyringa
purplesyringa / pdp11asm.md
Last active October 22, 2019 08:49
Syntax highlighting for PDP11ASM

Откройте папку с пакетами Sublime опцией Browse packages.... Перейдите в папку User и скопируйте туда приведенные ниже файлы.

Затем откройте любой исходник на ассемблере (файл с расширением .ASM или .MAC), выберите в списке языков (справа снизу) PDP-11 Asm. Затем в Preferences -> Color Scheme... выберите pdp11asm.


Open the directory with Sublime packages by pressing Browse packages.... Then open User subdirectory and copy the files below there.

Then open any assembler source (.ASM or .MAC), choose PDP-11 Asm in the language list (bottom right). Then open Preferences -> Color Scheme... and choose pdp11asm.

@pyrocto
pyrocto / overload.js
Last active June 5, 2024 16:13
A modest proposal for operator overloading in JavaScript
/*
It is a melancholy object-oriented language to those who walk through
this great town or travel in the country, when they see the JavaScript
programs crowded with method calls begging for more succinct syntax.
I think it is agreed by all parties, that whoever could find out a
fair, cheap and easy method of making these operators sound and useful
members of the language, would deserve so well of the publick, as
to have his statue set up for a preserver of the nation. I do therefore
humbly offer to publick consideration a pure JS library I've written
for overloading operators, which permits computations like these:
KWorker information
hostname: bc02e35d-d637-47c1-8b0e-aa77e20e4a12@1.worker-org-659784bb45-czzc7.gce-production-2
version: v6.2.5 https://github.com/travis-ci/worker/tree/0bd72df572e7d08bf9338416c9db10866fed0617
instance: travis-job-dbd31c8a-6c87-4703-bf20-1a9875efe9f7 travis-ci-sardonyx-xenial-1553530528-f909ac5 (via amqp)
startup: 6.378320099s
KBuild system information
Build language: python
Build group: stable
Build dist: xenial
Build id: 623740440