Skip to content

Instantly share code, notes, and snippets.

View jsrn's full-sized avatar
🌡️
being cool

James jsrn

🌡️
being cool
View GitHub Profile
@jsrn
jsrn / BasicUpload.php
Last active December 15, 2015 17:19
A short script to handle file upload in php.
<?php
/* * ****************************************************************************
* File uploader script.
* @author jsrn
*
* <form action="uploader.php" method="POST">
* <input type="file" name="file">
* <input type="submit" value="Upload">
* </form>
@jsrn
jsrn / RPGDice.py
Last active December 15, 2015 17:59
A random number generator to be used as a substitute for dice in a tabletop RPG. Given properly formatted input, outputs a series of random numbers, e.g. 4d12 rolls four 12-sided dice.
import random;
print "Usage:";
print "[N]d[M]";
print "where N is the number of dice and M is the size of the die.";
while 1:
try:
a = raw_input("Roll: ");
inp = a.split('d');
@jsrn
jsrn / Preferences.sublime-settings
Last active December 19, 2015 13:29
Sublime Text preferences
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"fade_fold_buttons": false,
"font_face": "Consolas",
"font_size": 13,
"highlight_line": true,
"ignored_packages":
@jsrn
jsrn / 100words.txt
Last active December 20, 2015 20:49
Python implementation of the Levenshtein distance finding algo
unpieced
superobedient
nonsacrificing
spikedace
outdare
superirritability
trainman
prevocalically
phonetician
paradrop
@jsrn
jsrn / rpxgen.py
Last active December 21, 2015 10:38
Because nobody likes getting RSI
# offset to start row number from - probably set it absurdly high to avoid conflicts
count = 200
baseheight = 552 # y coord of the first row
height_inc = 283 # default field height
num_rows = 30 # duh
row = 1 # row var
# Given the important details, returns a properly formatted Control element
def format_text_field( name, width, x ):
global count, row
@jsrn
jsrn / Brainhider.rb
Created November 4, 2013 13:44
Conceal Brainfuck in ASCII artwork
#!/usr/bin/env ruby
brainfuck = File.open("helloworld.bf", "rb").read
ascii_art = File.open("animaniacs.art", "rb").read
if brainfuck.length > ascii_art.gsub(" ","").length
abort "The supplied brainfuck will not fit inside the ASCII art."
end
@jsrn
jsrn / securuby.rb
Created November 29, 2013 11:18
My super secure crypto implementation
#!/usr/bin/env ruby
def print_block
puts "\e[H\e[2J"
chars = "ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyz0123456789#"
chars = chars.split("")
(1..20).each do |y|
(1..60).each do |x|
print chars.sample
@jsrn
jsrn / FlowersRubyExample.rb
Last active December 30, 2015 02:59
Flowers in Ruby
class Flowers
require "core/player.rb"
def initialize
print_banner
set_up_game
enter_game_loop
end
@jsrn
jsrn / gist:8648701
Created January 27, 2014 13:38
webcm vhost
<VirtualHost *:80>
ServerName webconstructionmanager
DocumentRoot /var/www/webconstructionmanager/public/
<Directory /var/www/webconstructionmanager/public>
AllowOverride All
</Directory>
</VirtualHost>
@jsrn
jsrn / FormHelper.php
Created May 2, 2014 08:53
Form Helper
<?php
class FormHelper {
public static function input($name, $placeholder, $value=null) {
echo '<input id="' . $name . '" name="' . $name . '"
placeholder="' . $placeholder . '" value="' . htmlentities($value) . '">';
}
public static function labelAndInput($name, $label, $value=null) {