Skip to content

Instantly share code, notes, and snippets.

View copyninja's full-sized avatar

Vasudev Kamath copyninja

View GitHub Profile
@copyninja
copyninja / wordlist.rs
Created April 27, 2018 16:41
Assert causes panic with HashSet<String>
use serde_json::{self, from_str, Value};
use std::collections::{HashMap, HashSet};
use util::{bytes_to_hexstr, random_bytes};
const RAW_WORDS: &'static str = r#"{
\"00\": [\"aardvark\", \"adroitness\"], \"01\": [\"absurd\", \"adviser\"],
\"02\": [\"accrue\", \"aftermath\"], \"03\": [\"acme\", \"aggregate\"],
\"04\": [\"adrift\", \"alkali\"], \"05\": [\"adult\", \"almighty\"],
\"06\": [\"afflict\", \"amulet\"], \"07\": [\"ahead\", \"amusement\"],
@copyninja
copyninja / playground.rs
Last active March 19, 2018 06:50 — forked from rust-play/playground.rs
Experiment for converting from String to HashSet and perform operations (Mainly for Column Transformation cipher)
use std::collections::HashSet;
use std::str::FromStr;
fn main() {
let alphabets = String::from_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ").unwrap();
let alpha_set: HashSet<_> = alphabets.split("").filter(|x| x.len() != 0).collect();
let keyword = String::from_str("SECRET").unwrap();
let keyword_set: HashSet<_> = keyword.split("").filter(|x| x.len() != 0).collect();
@copyninja
copyninja / csquery.py
Created August 28, 2014 11:28
CodeSearch query
import argparse
import requests
import sys
from collections import namedtuple
from bs4 import BeautifulSoup
CSResult = namedtuple('CSResult', ['pkg', 'version', 'file', 'href', 'lineno'])
def fetch_page(query):

Using WSME with Flask microframework

date

2014-06-02 20:30

slug

wsme-with-flask

tags

python, programming, wsme, rest

authors

copyninja

summary

This is short guide on how to use wsme with Flask applications, writing this because I felt documentation is lacking.

@copyninja
copyninja / dyanmic_module_loading.rst
Last active August 29, 2015 13:58
New post to publish

Loading python modules in run-time

date

2014-04-07 12:30

slug

dynamic-module-loading

tags

python, modules, import, programming

author

copyninja

summary

Post describes about loading arbitrary python files or modules during runtime.

@copyninja
copyninja / reverse_sentence.py
Created March 28, 2014 05:40
Code jam Affrical qualification round
import collections
def process(line, case):
words = line.split(' ')
n = len(words)
output = "Case #" + str(case) + ": "
if n == 1:
return output + words[0]
for i in range(n):
@copyninja
copyninja / store_credits.py
Created March 28, 2014 05:39
Code jam Affrical qualification round
def process(credits, nitem, items, case):
for i in range(nitem-1):
for j in range(i+1,nitem):
if int(items [i]) + int(items [j]) == credits:
return "Case #{}: {} {}".format(case, i+1, j+1)
def credit_difference(credits, items):
for item in items:
yield int(item), credits - int(item)
@copyninja
copyninja / float2byteslice.go
Created March 11, 2014 09:14
convert float to byte slice
package main
import (
"fmt"
"unsafe"
)
func main() {
var a = float32(-10.3)
var b = uintptr(unsafe.Pointer (&a))
@copyninja
copyninja / sgofmt.sh
Created March 10, 2014 05:55
Go source formatter for ACME editor
#!/bin/sh
# Copyright: (c) Vasudev Kamath <kamathvasudev@gmail.com>, 2014 under the
# terms and conditions of MIT/Expat.
tmp=$(mktemp --tmpdir=$(pwd))
etmp=$(mktemp --tmpdir=$(pwd))
cleanup() {
rm -f "$tmp" "$etmp"