Skip to content

Instantly share code, notes, and snippets.

@kylelk
kylelk / popcount.c
Created October 16, 2015 02:12
sqlite extension to calculate population bit count
/* compile osx
* gcc -bundle -fPIC -O3 -o popcount.dylib popcount.c
* */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1
@kylelk
kylelk / pop_count.s
Created May 7, 2015 03:17
ARM assembly population count using NEON instructions. compile with: gcc -mfpu=neon pop_count.s
.text
.global main
main:
ldr r0, =value
ldr r0, [r0]
vmov.32 d0[0], r0
vcnt.8 d0, d0
vmov.32 r0, d0[0]
add r0, r0, r0, lsr #16
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
public class AESexample {
private String keySize;
private Key aesKey;
@kylelk
kylelk / sha256.py
Created December 27, 2013 21:15
Python implantation of sha256
def sha256(data):
bytes = ""
h0 = 0x6a09e667
h1 = 0xbb67ae85
h2 = 0x3c6ef372
h3 = 0xa54ff53a
h4 = 0x510e527f
h5 = 0x9b05688c
h6 = 0x1f83d9ab
import sys, math, pygame
class Point3D():
def __init__(self, x=0, y=0, z=0):
self.x, self.y, self.z = float(x), float(y), float(z)
def rotateX(self, angle):
""" Rotates the point around the X axis by the given angle in degrees. """
rad = angle * math.pi / 180
#
# By Kyle Kersey
# 2014
#
import praw
import sqlite3
import sys
database_path = "reddit_comments.db"
@kylelk
kylelk / diff_test.py
Created April 25, 2016 00:21
python difflib example
import difflib
# output
# the(insert " fast and") quick brown (replace "fox" with "duck") jumped over the lazy (replace "dog" with "cat")
s1 = 'the quick brown fox jumped over the lazy dog'
s2 = 'the fast and quick brown duck jumped over the lazy cat'
def show_diff(seqm):
@kylelk
kylelk / redis_client.adb
Last active April 22, 2016 01:47
How to connect to a Redis server using Ada
with GNAT.Sockets;
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Streams; use Ada.Streams;
procedure Redis_Client is
package TIO renames Ada.Text_IO;
package UBS renames Ada.Strings.Unbounded;
Host : constant String := "127.0.0.1";
diff --cc app/views/landing_page/index.html.erb
index 049ff5f,4f1c60f..0000000
--- a/app/views/landing_page/index.html.erb
+++ b/app/views/landing_page/index.html.erb
@@@ -9,7 -9,72 +9,77 @@@
</div>
</div>
-->
-
<div class="main-landing-content">
@kylelk
kylelk / highlight.py
Created January 28, 2014 03:34
Create highlighted listings of files
# -*- coding: utf-8 -*-
import pygments
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
from pygments.lexers import guess_lexer, get_lexer_for_filename
from os import listdir, mkdir
from os.path import isfile, join, getsize, getctime, isdir, dirname, abspath
from time import ctime
import glob