Skip to content

Instantly share code, notes, and snippets.

View tekknolagi's full-sized avatar
🚴

Max Bernstein tekknolagi

🚴
View GitHub Profile
@tekknolagi
tekknolagi / diff types
Created October 17, 2011 19:53
array diff types
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define int(x) *((int *) x)
int main() {
void *a[2];
char *b = "hello";
words = [line.strip().lower() for line in open('/usr/share/dict/words')]
words = [i for i in words if "q" in i]
w = []
for i in words:
if i.replace("q", "o") in words:
w.append(i)
print i
print len(w)
<?php
/*
* Bitstorm - A small and fast Bittorrent tracker
* Copyright 2012 Peter Caprioli <peter@caprioli.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
class Brightswipe < Sinatra::Base
configure do
enable :run
set :app_file, __FILE__
set :views, "#{settings.root}/../views"
$pubdir = "public/i"
unless File.directory? "public"
Dir.mkdir "public"
unless File.directory? $pubdir
#!/bin/sh
# Read _why's SPOOL in real time.
# Requires `lp` and a printer.
BASEURL=http://whytheluckystiff.net
if [ ! -d SPOOL ]; then
mkdir SPOOL
fi
@tekknolagi
tekknolagi / gist:5869548
Created June 26, 2013 17:38
How to install a LAMP stack on Arch Linux
<script type="text/javascript">
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
@tekknolagi
tekknolagi / gist:5869875
Last active December 19, 2015 00:39
How to install and get started with Sinatra
<h1 id="how-to-install-and-get-started-with-sinatra">How to install and get started with Sinatra</h1>
<h2 id="introduction">Introduction</h2>
<hr />
<p>Sinatra is a simple and lightweight web framework written in Ruby. This article assumes you know basic Ruby and have Ruby and RubyGems installed on your system. Using Ruby Version Manager (RVM) is preferable.</p>
<h3 id="its-not-rails-what-is-it">It's not Rails. What is it?</h3>
<p>Sinatra is similar to Ruby on Rails in that they are both web frameworks. It's pretty different from Rails in that it's much lighter (less overhead), and you have more fine-grained control over your webapp. Additionally, there is no built-in database functionality or page rendering &mdash; all of that is done manually.</p>
<h3 id="why-sinatra-then">Why Sinatra, then?</h3>
<p>It's fast. It's simple. It's efficient. There is less to be learned. It allows flexibilty that Rails does not. However, with that comes more work and more room for error.</p>
<p>Sinatra is best used for smaller
require 'data_mapper'
require 'dm-postgres-adapter'
require 'pry'
#DataMapper.setup :default, ENV['HEROKU_POSTGRESQL_AQUA_URL']
DataMapper.setup :default, 'postgres://uwgnmutktlckej:uACT6pxYLaDg7qDYh7PlQYOVLo@ec2-54-235-173-50.compute-1.amazonaws.com:5432/degihk3bc71vk4'
class User
include DataMapper::Resource
require 'data_mapper'
require 'dm-postgres-adapter'
require 'pry'
#DataMapper.setup :default, ENV['HEROKU_POSTGRESQL_AQUA_URL']
DataMapper.setup :default, 'postgres://uwgnmutktlckej:uACT6pxYLaDg7qDYh7PlQYOVLo@ec2-54-235-173-50.compute-1.amazonaws.com:5432/degihk3bc71vk4'
class User
include DataMapper::Resource
require 'pp'
class ShitVM
attr_accessor :regs
attr_reader :ops
def initialize
@regs = {}
@ops = {
:loadi => ->(reg, val) {