Skip to content

Instantly share code, notes, and snippets.

View pulsejet's full-sized avatar

Varun Patil pulsejet

View GitHub Profile
@pulsejet
pulsejet / build_config.rb
Created May 5, 2018 02:29
Toolchain for building mruby with emscripten
# Sample usage
MRuby::CrossBuild.new('emscripten') do |conf|
toolchain :emscripten
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :github => 'take-cheeze/mruby-marshal'
conf.gembox 'default'
conf.cc do |cc|
cc.flags = [ENV['CFLAGS'] || %w()]
cc.compile_options = "%{flags} -O3 -MMD -o %{outfile} -c %{infile} -I$HOME/dev/onig/src"
@pulsejet
pulsejet / float_div.patch
Created May 5, 2018 02:30
Patch to force 1/2 == 0 in mruby
From e36e2760f2c168c179a35cc8bf7a4103ce523f61 Mon Sep 17 00:00:00 2001
From: Rob Lyman <[email protected]>
Date: Sat, 20 Jan 2018 13:52:04 -0600
Subject: [PATCH 1/2] Updated support for integer division behavior
This adds an adapted fix to give conditional integer division support,
based on the environment variable MRB_INTEGER_DIVISION. This adapts from
the previous fix to the latest stable mRuby branch, taking into
account their new MRB_WITHOUT_FLOAT environment variable.
@pulsejet
pulsejet / mkxp_mruby.md
Last active May 5, 2018 06:33
Guide for mkxp with mruby

mkxp + mruby = ❤

RGSS Script Changes

Language differences

Replace all instances of

begin
    statement
end until condition

with

@pulsejet
pulsejet / verbs.csv
Created May 21, 2018 07:19
Verb dataset
present thrid_person continuous past
abandon abandons abandoning abandoned
abase abases abasing abased
abate abates abating abated
abbreviate abbreviates abbreviating abbreviated
abdicate abdicates abdicating abdicated
abduct abducts abducting abducted
abet abets abetting abetted
abhor abhors abhorring abhorred
abide abode abided abides
@pulsejet
pulsejet / sep_xml.py
Created May 31, 2018 10:49
Separate xml files removing tags (CRUDE)
import xml.etree.ElementTree as ET
tree = ET.parse('xmlsdev.xml')
root = tree.getroot()
with open('corrected', 'w', encoding='utf-8') as file:
i = 0
for sentence in root.iter('sentence'):
for child in sentence.findall('del'):
tail = child.tail
child.clear()
@pulsejet
pulsejet / diff_from_xml.py
Created May 31, 2018 13:47
Gets the diffs direct from XML
# NOTE: Currently this prints the diff for the second data element and exits
import nltk
import xml.etree.ElementTree as ET
import copy
import difflib
tree = ET.parse('xmlsdev.xml')
root = tree.getroot()
import nltk
import xml.etree.ElementTree as ET
import copy
import difflib
tree = ET.parse('xmlsdev.xml')
root = tree.getroot()
def xml_stringify(node):
return "".join(node.itertext())
@pulsejet
pulsejet / login.sh
Created June 2, 2018 05:42
Script to login to IITB Network
#!/bin/bash
if [[ -n $1 ]]
then
UNAME=$1
else
read -p 'Username: ' UNAME
[[ -z $UNAME ]] && exit 1
fi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pulsejet
pulsejet / resize-images.py
Created September 28, 2018 15:30
Resize images and convert to progressive JPG with pillow
from os import listdir
from os.path import isfile, join
from PIL import Image
mypath = '.'
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f)) and '.jpg' in f]
MAX_DIM = 800
for path in onlyfiles: