Skip to content

Instantly share code, notes, and snippets.

View shibasisp's full-sized avatar

Shibasis Patel shibasisp

View GitHub Profile
@shakna-israel
shakna-israel / LetsDestroyC.md
Created January 30, 2020 03:50
Let's Destroy C

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@gaurav-gogia
gaurav-gogia / threaded.go
Created March 20, 2019 17:10
copying from src to dst big file
func (dd *opts) run() error {
var thread int64
var names []string
done := make(chan bool)
size := getsize(*dd.src)
for i := int64(0); i < size; i += *dd.buffersize {
dstname := partfile + strconv.FormatInt(i, 10)
names = append(names, dstname)
@liveashish
liveashish / spamhaha.py
Last active March 19, 2019 03:17
Sarahah spam bot: A life saver! 🔥 💪
import time
import requests
users_to_attack = ['USER_NAME', ] #list of users to be attacked
def sarahah_post(user, msg):
s = requests.Session()
homeurl = 'https://' + user + '.sarahah.com/'
home = s.get(homeurl)
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@tkrajina
tkrajina / unmarshal_interface.go
Last active June 22, 2024 14:24
Unmarshal JSON to specific interface implementation
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Something interface{}
@vishnus
vishnus / bns.js
Created November 30, 2016 06:55
Black and Scholes formula in JS
function bns() {
// Sample input
spot = 8400;
strike = 8600;
expiry = "2016-12-01 23:59:00";
volt = 18;
int_rate = 7;
div_yld = 0;
//Validation
@anvk
anvk / promises_reduce.js
Last active October 11, 2023 09:02
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@adam-p
adam-p / Local PR test and merge.md
Last active February 5, 2024 19:39
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37