Skip to content

Instantly share code, notes, and snippets.

View DavideGalilei's full-sized avatar
🐝

Davide Galilei DavideGalilei

🐝
View GitHub Profile
@diegopacheco
diegopacheco / latest-protobuf-ubuntu-18-04.md
Created June 7, 2018 20:13
How to Install Latest Protobuf on Ubuntu 18.04
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
make
make check
sudo make install
sudo ldconfig

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@cfra
cfra / memtest-flashdrive.md
Last active March 26, 2021 07:40
Memtest from USB flash drive

Memtest on USB flash drive

Using Memtest86 Free Edition

At the time of writing, this installed V7.4 for UEFI and V4 for BIOS boot.

Caution: you have to use the correct device name for your flashdrive

wget https://www.memtest86.com/downloads/memtest86-usb.tar.gz
@AnthonyPanchenko
AnthonyPanchenko / lerp.js
Created October 27, 2017 15:48 — forked from Anthodpnt/lerp.js
Math - Linear Interpolation
/**
* This gist is for Javascript beginners.
* @author: Anthony Du Pont <[email protected]>
* @site: https://www.twitter.com/JsGists
*
* Linear Interpolation is a method to add some natural behaviors to your animations. The more natural
* your animations look like, the better will be the look-and-feel. But what's Linear Interpolation ?
*
* Linear Interpolation, also called `lerp`, is a way of easing your animation. Imagine you want to
* move a box from a position A to a position B. Without the Linear Interpolation, you box will
// Djb2 hash function
unsigned long hash(char *str) {
unsigned long hash = 5381;
int c;
while ((c = *str++))
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash % NUM_BUCKETS;
}
# This is an example of hash length extension attacks (and why you don't roll your own crypto!!!)
# In this case, an attacker, Malice, intercepts a message ("to=12345&amt=103.53&note=Thanks!")
# that has been "authenticated" using a poorly constructed MAC (message authentication code).
# This MAC has been created using the following method: md5(secret | message).
# Ideally, since the attacker, Malice, doesn't have the secret, he should be unable to craft a new
# message that is also authenticated. However, because of how the mac was created, we can use
# Hash Length Extensions. We'll be using the pymd5 library as found on upenn's website via google cache:
# https://webcache.googleusercontent.com/search?q=cache:yyvXXyVKuYYJ:https://www.cis.upenn.edu/~cis331/project1/pymd5.py+&cd=3&hl=en&ct=clnk&gl=us
import urllib
@pjeby
pjeby / shelldown-demo
Last active May 28, 2025 08:18
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)

@cryptolok
cryptolok / vMetaDate.sh
Last active November 15, 2025 13:25
small tool to retreive vk.com (vkontakte) users hidden metadata (state, access, dates, counts, etc) anonymously (without login)
#!/bin/bash
# small tool to retreive vk.com (vkontakte) users hidden metadata (state, access, dates, counts, etc) anonymously (without login)
# sudo apt install curl
parse(){
local IFS=\>
read -d \< CELL VALUE
}
@mratsim
mratsim / chaining.nim
Created May 24, 2017 23:26
Nim inline iterator chaining macro
## From https://forum.nim-lang.org/t/2856
import macros
macro chaining(code: untyped): untyped =
const chainIdent = "chain"
const combineIdent = "combine"
proc inspect(depth: int, n: NimNode): NimNode =
case(n.kind)
of nnkIdent, nnkStrLit:
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A