Skip to content

Instantly share code, notes, and snippets.

View blendax78's full-sized avatar

Eric Vintimilla blendax78

View GitHub Profile
@blendax78
blendax78 / is_prime.py
Created October 4, 2017 20:28
Prime Number Calculator
import time
def is_prime(num):
start = time.time()
p = False
i = 2
while i < num and not p:
p = num % i == 0
i += 1
end = time.time()
if not p:
@blendax78
blendax78 / git_clean.sh
Created April 14, 2014 17:12
Remove extra Git branches (other than develop & master)
#!/bin/bash
ls="$(ls)"
for i in $(git branch)
do
if [[ "$i" != "develop" && "$ls" != *$i* && "$i" != "master" ]]
then
echo "Removing $i..."
git branch -D $i
fi
@blendax78
blendax78 / config
Created March 27, 2013 20:14
SSH Config for sshing into servers by using an alias. Automatically tells it which user to use. (Copy to .ssh/config)
ServerAliveInterval 5
Host *
User <username>
Host <alias>
HostName <host address>
Host <alias2>
HostName <host address 2>
@blendax78
blendax78 / calculate_dist.js
Created March 25, 2013 01:26
Functions to calculate the distance (in miles with extra function or kilometers by default) between two latitude and longitude points. Works well with Google's JSAPI.
function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
@blendax78
blendax78 / get_fb_info.php
Created March 15, 2013 15:29
Do a quick Facebook search for a particular user.
<?php
function get_fb_info($facebook_name){
// Example: https://graph.facebook.com/digimantra
$data = json_decode(file_get_contents("https://graph.facebook.com/".$facebook_name));
var_dump($data);
}
?>
@blendax78
blendax78 / see_source.php
Created March 15, 2013 15:17
Display source code of a webpage
<?php // display source code
# Example: $url = 'http://google.com';
$lines = file($url);
foreach ($lines as $line_num => $line) {
// loop thru each line and prepend line numbers
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
?>
@blendax78
blendax78 / wikipedia.sh
Created February 26, 2013 02:12
Search wikipedia from the command line.
#!/bin/bash
#
# wikipedia.sh
#
numargs=$#
if [ $numargs -lt 1 ]
then
@blendax78
blendax78 / dvd_to_iso.sh
Created February 26, 2013 02:04
Creates an ISO of a DVD.
#!/bin/bash
# requires 1 parameter (output file name & location)
# usage:
# sh dvd_to_iso.sh '~/Documents/output.iso'
dd if=/dev/dvd of="$1"