Skip to content

Instantly share code, notes, and snippets.

View Siddhartha90's full-sized avatar

Siddhartha Siddhartha90

View GitHub Profile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
set -x
echo I am provisioning...
date > /etc/vagrant_provisioned_at
apt-get update
echo "America/Los_Angeles" | sudo tee /etc/timezone
ntpdate -u pool.ntp.org
import java.util.*;
public class decodingcountDP {
static int calls = 0;
static Map<Integer, String> codes = new HashMap<Integer, String>();
private static void construct(){
codes.put(1, "A");
codes.put(2, "B");
@Siddhartha90
Siddhartha90 / findlatestbuild.pl
Created February 19, 2015 22:56
Find Last Build Run
use strict;
use warnings;
use ElectricCommander;
# Turn off buffering
$| = 1;
my $ec = new ElectricCommander();
my $xpath = $ec->findObjects("job",
@Siddhartha90
Siddhartha90 / UpdateBuildWidget.pl
Created February 19, 2015 23:00
Send to Welcome Widget
if [ "$[/myJob/latestBuildOutcome]" = "success" ]
then
outcome="Green"
curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Latest Build - $[/myJob/latestBuild] ran for '$[/myJob/latestBuildElapsedTime]' hours, and was '$outcome' woo! ", "isGreen": 3}' \http://yourdashingurl:3030/widgets/welcome
else
outcome="Red"
curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "$[/myJob/latestBuild] ran for $[/myJob/latestBuildElapsedTime] hours, and was '$outcome'! ", "isRed": 3}' \http://yourdashingurl:3030/widgets/welcome
fi
@Siddhartha90
Siddhartha90 / CSV.py
Created January 26, 2014 00:31
Py script to convert a text file containing data to a mahout datafile format, which is values separated by commas(CSV)
def main():
myfile = open('words.txt', 'r')
outfile = open('wordsoutput.txt', 'w')
for line in myfile:
line_list = line.split('::')
new_line = ','.join(line_list[:-1])
outfile.write(new_line)
outfile.write('\n')
@Siddhartha90
Siddhartha90 / movie.py
Created January 26, 2014 00:37
another script to pull out movie from the movies.dat file
def main():
myfile = open('result.txt', 'r')
myfile2 = open('movies.txt', 'r')
myfile3 = open('finalrecos.txt', 'w')
content = myfile2.read()
i = 0
for line in myfile:
m = re.search(r'(?<=RecommendedItem\[item:)(\d+)',line)
i+=1
n = re.search(r'(?<='+m.group(0)+r'\:\:)(.+)(?=::)',content)
@Siddhartha90
Siddhartha90 / anonymize-emails.py
Last active February 6, 2018 13:13
A python script which anonymizes email addresses in all files in current directory and sub-directories.
# A python script which anonymizes email addresses in all files in current directory and sub-directories.
# e.g. A file with the following contents:
# siddhartha@gmail.com
# Sid Phn#- 6385833322
# gupta49@illinois.edu
# weee@as.cd
# sid@yahoo.co.in
# Would change to:
@Siddhartha90
Siddhartha90 / server.py
Created January 10, 2020 00:20 — forked from raelmax/server.py
Python3 http.server com sleep
import http.server
import socketserver
from time import sleep
PORT = 5000
SLEEP_TIME = 6
class SlowHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
sleep(SLEEP_TIME)
ls
mkdir basicscript