Skip to content

Instantly share code, notes, and snippets.

View Antrikshy's full-sized avatar

Antriksh Yadav Antrikshy

View GitHub Profile
@Antrikshy
Antrikshy / Letter_Permutations.py
Last active August 29, 2015 14:00
Python script to count the number of ways letters in a string (passed in as argument) can be rearranged
# USAGE: python Letter_Permutations.py <string here>
# Do not put spaces between multiple words in the string
import argparse
import math
# Reads word from argument
parser = argparse.ArgumentParser()
parser.add_argument('word', help = "Word to count combinations for")
args = parser.parse_args()
@Antrikshy
Antrikshy / switch_to_server.sh
Created June 28, 2014 02:21
Makes it easy to switch Bukkit/SpigotMC Minecraft server worlds. We have two worlds on our Raspberry Pi and switching requires backing up one world and moving the other out of backup. This automates the process and also runs the server afterwards (can also run current world using "run" argument).
#!/bin/bash
if [ $# -ne 2 ]
then
if [ "$1" != "run" ]
then
echo "Usage: $0 <world to backup> <world to unpack>"
echo "For best results, run with sudo."
exit
else
java -Xms256M -Xmx496M -jar -XX:MaxPermSize=128M /home/pi/SpigotMC/spigot.jar nogui
@Antrikshy
Antrikshy / MCScreensToDesk.sh
Created July 5, 2014 10:49
Tiny script to be added to PATH that copies over Minecraft's screenshots folder to Desktop (on Linux/Mac)
#!/bin/bash
cp -rf ~/Library/Application\ Support/minecraft/screenshots ~/Desktop/
@Antrikshy
Antrikshy / tester-pa3.py
Last active May 1, 2016 20:44
CSE 100 Fall '14 Network Planning (pa3) Tester
#!/usr/bin/env python
import os, sys, subprocess, time
import filecmp as fc
# --------------------------------------------------------------------------------------------------------
# Backport of Python 2.7's subprocess.check_output function from https://gist.github.com/edufelipe/1027906
def check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
@Antrikshy
Antrikshy / websitename.conf
Last active August 29, 2015 14:18
Upstart config for Express.js app
# Goes in /etc/init/
description "Blah server"
start on startup
start on filesystem and started networking
stop on shutdown
respawn
chdir /home/username/folder
@Antrikshy
Antrikshy / quibbler.conf
Created April 11, 2015 07:15
nginx config for Quibbler.co, Express.js apps listening on port 3000
# Goes in /etc/nginx/conf.d/
upstream quibbler {
server 127.0.0.1:3000;
}
server {
listen 0.0.0.0:80;
server_name quibbler.co www.quibbler.co;
@Antrikshy
Antrikshy / majority_element.py
Last active August 29, 2015 14:19
O(nlogn) majority element algorithm
def majority_element(a):
n = len(a)
if n == 1:
return a[0]
if n == 0:
return None
k = n/2
elem1 = majority_element(a[:k])
elem2 = majority_element(a[k+1:])
@Antrikshy
Antrikshy / data_split.py
Last active May 17, 2022 09:07
Simple, configurable Python script to split a single-file dataset into training, testing and validation sets
import random
import math
# Configure paths to your dataset files here
DATASET_FILE = 'data.csv'
FILE_TRAIN = 'train.csv'
FILE_VALID = 'validation.csv'
FILE_TESTS = 'test.csv'
# Set to true if you want to copy first line from main
@Antrikshy
Antrikshy / job_hunt.sh
Created August 11, 2016 07:20
Tired of manually trudging through website source code for easter eggs and invitations to apply for jobs?
declare -a arr=("google.com" "facebook.com"
"amazon.com" "yahoo.com" "flickr.com"
"youtube.com" "twitter.com" "reddit.com") # etc etc
for i in "${arr[@]}"
do
echo "$i"
curl -L --silent "$i" | grep -E "hiring|jobs"
# Maybe even look for easter eggs this way!
done
@Antrikshy
Antrikshy / lang_by_dev_type.py
Created June 5, 2019 05:31
Script to re-process Stack Overflow Developer Survey 2019 data to get tech popularity stats by self-reported developer type
import csv
from collections import Counter
have_tally = {}
want_tally = {}
# Get the dataset at insights.stackoverflow.com/survey
path_to_datum = '/path/to/downloaded/developer_survey_2019/survey_results_public.csv'
# This *should* work without too much modification with SO survey datasets from other