Skip to content

Instantly share code, notes, and snippets.

@yousefamar
yousefamar / spawn.sh
Last active August 29, 2015 14:06
Runs a command multiple times in new terminals with different arguments
#!/usr/bin/sh
#
# Runs a command multiple times in new terminals with different arguments
#
# Authors:
# Yousef Amar <yousef@amar.io>
#
@yousefamar
yousefamar / WebLogin.java
Created September 21, 2014 17:30
An example of command-line login into a web server using Java
import java.io.*;
import java.net.*;
public class WebLogin {
public static String login(String username, String password) {
//TODO: Add version parameter.
String parameters = "username="+username+"&password="+password;
HttpURLConnection connection = null;
try {
@yousefamar
yousefamar / int2bin.cpp
Last active August 29, 2015 14:06
A small program that prints integers in binary
#include <iostream>
using namespace std;
bool bitTest(unsigned int num, int bit) {
return ((1<<bit)&num)>0;
}
void printBin(unsigned int num) {
int i;
cout << num <<" in binary is: ";
@yousefamar
yousefamar / flower.py
Created September 22, 2014 19:30
A old failed attempt at drawing a flower with turtle graphics
# So I finally try messing with Python and what better way to try for-loops that with turtle gfx.
from turtle import *
import time
color("blue")
up()
goto(0,100)
down()
circle(50)
@yousefamar
yousefamar / scramble-search.py
Created September 22, 2014 19:55
A short script, written for a HackThisSite.org programming mission, that takes 10 scrambled inputs, searches for anagrams for them in a text file, and outputs them
import os
import sys
words = []
answers = ['']*10
print "Enter 10 scrambled terms."
for i in range(10):
words.append(raw_input().strip())
@yousefamar
yousefamar / search.py
Created September 26, 2014 18:35
A old python script that walks a directory and searches files for a specified term
import os
sTerm = raw_input("Search term: ")
for root, dirs, files in os.walk("."):
print root
for fname in files:
print " "+fname
with open(root+os.sep+fname) as f:
flines = f.readlines()
@yousefamar
yousefamar / IPScanner.java
Created December 17, 2014 01:27
A program that repeatedly lists the IP addresses of all devices on a LAN at one second intervals
import java.net.*;
import java.lang.*;
import java.util.*;
public class IPScanner implements Runnable {
// Create a list in which to store live host IP addresses
static List<String> ips = Collections.synchronizedList(new ArrayList<String>());
private String ip;
@yousefamar
yousefamar / 4scrape.py
Created March 12, 2015 15:06
A 4chan banner scraper
import urllib
import time
import os
if not os.path.exists("imgs"):
os.makedirs("imgs")
for i in xrange(1,260):
urllib.urlretrieve("http://s.4cdn.org/image/title/"+str(i)+".png", "imgs/"+str(i)+".png")
time.sleep(1)
#!/usr/bin/env lsc
w = 0.5
_w = 1 - w
n1 = 50
n2 = 100
mem = 0
i = 0
do
#!/usr/bin/env lsc
w = 0.5
_w = 1 - w
n1 = 50
n2 = 100
mem = 0
i = 0
do