Skip to content

Instantly share code, notes, and snippets.

@theSage21
theSage21 / organize.sh
Created February 1, 2018 07:29
Rajasthan Anganwadi content creater
wget https://drive.google.com/file/d/1M8kRWh-pt-CiSXtXSMX68YTwB7ibCB4C/view?usp=sharing -O small.zip
unzip small.zip
rm -rf uploads
cp -r Anganwadi-upload uploads
cd uploads
mv 'pdf/activity bank' 'Activity Bank'
mv 'pdf/activity book' 'Activity Book'
mv 'pdf/Child Assesment Card' 'Child Assessment Card'
mv 'pdf/curriculam' 'Curriculum'
mv 'pdf/syllabus' 'Syllabus'
{
"wrappers": {
"python3": "ulimit -m {memory_limit} && ulimit -t {time_limit} && python3 '{code}' < '{input}'",
"python2": "ulimit -m {memory_limit} && ulimit -t {time_limit} && python2 '{code}' < '{input}'",
"perl5": "ulimit -m {memory_limit} && ulimit -t {time_limit} && perl '{code}' <'{input}'",
"lua": "ulimit -m {memory_limit} && ulimit -t {time_limit} && lua '{code}' <'{input}'",
"g++": "g++ '{code}' -o '{code}.compiled' && ulimit -m {memory_limit} && ulimit -t {time_limit} && '{code}.compiled' <'{input}'",
"java(use 'class Solution')": "mkdir 'dir_{code}' && mv '{code}' 'dir_{code}/Solution.java' && cd 'dir_{code}' && javac Solution.java && ulimit -m {memory_limit} && ulimit -t {time_limit} && java Solution < '{input}' && cd .. ; rm -rf 'dir_{code}'",
"gcc": "gcc '{code}' -o '{code}.compiled' && ulimit -m {memory_limit} && ulimit -t {time_limit} && '{code}.compiled' <'{input}'"
},
@theSage21
theSage21 / imagecat.py
Created January 24, 2018 03:19
Concatenate images side by side.
from scipy.misc import imread, imsave
import numpy as np
import os
# Place images of same size in folder called images.
# name them in the order you want them to appear in.
# run script.
# view file all.png
images = list([os.path.join('images', i)
var script = document.createElement("script");
script.setAttribute("src", "http://localhost:8000/static/bot.js");
document.body.appendChild(script);
from keras import layers as L
from keras import models as M
inputs = L.Input((4, ))
output = L.Dense(3)(inputs)
model = M.Model(inputs, outputs)
model.compile('sgd', 'mse')
import numpy as np
@theSage21
theSage21 / tf-xor.py
Created September 20, 2017 07:30
Tensorflow 1.3 XOR
import tensorflow as tf
import numpy as np
x = np.array([[0, 0],
[0, 1],
[1, 0],
[1, 1]]*100)
y = np.array([0, 1, 1, 0]*100).reshape((-1, 1))
@theSage21
theSage21 / SSCattendance.ipynb
Created February 16, 2017 15:50
Get the data, reformat and plot stuff for SSC attendance
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@theSage21
theSage21 / C_codechef_viz.py
Created December 9, 2016 01:55
Visualizing C programs from the Codechef database.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import networkx as nx
import pickle
from collections import deque
import multiprocessing as mp
import editdistance
import os
@theSage21
theSage21 / perceptron.py
Created August 11, 2016 17:34
Simple perceptron code.
# AUTHOR: Arjoonn Sharma
# LICENSE: MIT
# Recommended Reading before tinkering with code:
# https://en.wikipedia.org/wiki/Heaviside_step_function
# https://en.wikipedia.org/wiki/Perceptron
def dot_product(vector1, vector2):
"Returns the dot product between two vectors"
# assertions allow us to make sure some things are true before
# we proceede. Here dot product is only defined for vectors
@theSage21
theSage21 / get_back.py
Created July 31, 2016 07:37
Warns you when you get too close to the screen
import os
import time
import cv2
import sys
print('python script.py harr.xml 1')
print(sys.argv)
script, casc, nodisplay = sys.argv
nodisplay = (nodisplay == '0')