Skip to content

Instantly share code, notes, and snippets.

View mcnemesis's full-sized avatar
💭
DNAP hackathons on days with good weather ;-)

Nemesis Fixx Da JWL mcnemesis

💭
DNAP hackathons on days with good weather ;-)
View GitHub Profile
def verify_sign(public_key_loc, signature, data):
'''
Verifies with a public key from whom the data came that it was indeed
signed by their private key
param: public_key_loc Path to public key
param: signature String signature to be verified
return: Boolean. True if the signature is valid; False otherwise.
'''
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
@sergeifilippov
sergeifilippov / domain-nginx.conf
Created February 10, 2014 03:22
linux-dash with nginx
server {
server_name $domain_name;
root /var/www;
index index.html index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Cache static files for as long as possible
location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
try_files $uri =404;
@mcnemesis
mcnemesis / uganda_districts.txt
Created June 4, 2014 07:23
List of all current (as of 2014) Uganda's Districts - useful in forms-authoring and other tasks of your liking (source : http://www.statoids.com/uug.html)
Abim
Adjumani
Agago
Alebtong
Amolatar
Amudat
Amuria
Amuru
Apac
Arua
@mcnemesis
mcnemesis / upgrade_wordpress_wpcli.sh
Last active August 29, 2015 14:25
This is how to upgrade your WordPress site, its plugins and themes automatically via a shell, using wp-cli
#!/bin/bash
#requires: wp-cli installed
# run all the following commands inside your wordpress root directory
wp core update #updates wp itself
wp plugin update --all #update all plugins
wp theme update -all #update all themes
@cachapa
cachapa / gif_creator.sh
Last active April 1, 2022 12:07
Shell script to generate high-quality animated gifs from a video file
#!/bin/bash
# Based on http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
# Requires ffmpeg
filename="${1%.*}"
palette="/tmp/palette.png"
filters="scale=320:-1:flags=lanczos"
ffmpeg -v warning -i "$1" -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i "$1" -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y "$filename.gif"
@francisnnumbi
francisnnumbi / LineNumberedEditText
Created May 16, 2017 08:32
implementing an EditText with line number on the left. What is new is: - get/set line number margin gap - set line number visible - set line number color Everything is done in the overridden onDraw() method.
import android.widget.*;
import android.util.*;
import android.content.*;
import android.graphics.*;
/**
* the simple implementation of an EditText where each line is numbered on the left
*/
public class LineNumberedEditText extends EditText {
@radekk
radekk / entropy.js
Created June 7, 2017 18:16
Calculating Shannon's entropy with JavaScript
/**
* Calculate Shannon's entropy for a string
*/
module.exports = (str) => {
const set = {};
str.split('').forEach(
c => (set[c] ? set[c]++ : (set[c] = 1))
);
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@mcnemesis
mcnemesis / MainActivity.java
Last active November 2, 2020 17:09
Example Activity using the DNAP Histrion as an embed
package com.nuchwezi.nulabs;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@mcnemesis
mcnemesis / DRAMON.default.config.json
Last active July 6, 2020 08:18
Sample DRAMON Configuration
{"DRINK":["Soda","Water","Something Hot","Tea","Some Wine","Milk","Yorghurt","Beer","Spirit","Porridge","A Herb.","some Fresh Juice","Bushera","Warm Water"],"CALL":["A Girlfriend","A Relative","Your Friend","someone you miss."],"EAT":["A Fruit","Leafy Vegetables","Fish","Nuts","Something Starchy","No meat","Chicken","some Seeds"],"GO TO":["Entebbe","A Forest","The Lake","Kampala","Home","School","a dance floor.","Bed.","work. "],"Summon":["God","Guardian Angel","Allself","Certain","your muse."],"LISTEN TO":["Some Nu Music","A Podcast","Old Hip Hop","Ragga!","Jazz","Some music.","Something you can play yourself, using things around you.","Traffic"],"WATCH":["A Music Video","A Science Video","Some News","A Cartoon","A Movie","A Comedy","Nature","Your Inner World","Something Erotic","The Skies."],"READ":["from SHRINES, by JWL.","a Holy Scripture.","One of your old documents.","Poetry","A Novel","the News","the Clouds","that book. "],"RITE":["Alone","With Someone else. (No more than 5).","With Someone else. (No m