Skip to content

Instantly share code, notes, and snippets.

View dmadisetti's full-sized avatar
🇩🇲
Set status

Dylan Madisetti dmadisetti

🇩🇲
Set status
View GitHub Profile
@dmadisetti
dmadisetti / Corresponding Node Server
Last active December 17, 2015 13:59 — forked from frockenstein/GreasemonkeyUpload.js
Craigslist with auth
// Hats off to https://gist.github.com/hackable/1294667
var express = require('express'),
request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys'),
fs = require('fs');
var app = express.createServer();
@dmadisetti
dmadisetti / WPtweet
Created May 24, 2013 05:28
Minimalist Twitter API status post from wordpress.
function tweet($status){
$oauth_consumer_key = "key";
$oauth_token = "token";
$oauth_signature_method = "HMAC-SHA1";
$oauth_timestamp = time();
$oauth_nonce = hash("md5","Random" . $oauth_timestamp . "32 bit string");
$baseurl = "https://api.twitter.com/1.1/statuses/update.json";
$url= '';
$url.= "?oauth_consumer_key=".rawurlencode($oauth_consumer_key);
$url.= "&oauth_nonce=" . rawurlencode($oauth_nonce);
@dmadisetti
dmadisetti / Rage proof
Created June 13, 2013 02:37
Quick hack to verify this rage comic http://wheresmysammich.com/images/34082.jpg for numbers 0-100000. Counter intuitive at first glance but makes sense on closer look
to20 = [
'zero'
,'one'
,'two'
,'three'
,'four'
,'five'
,'six'
,'seven'
@dmadisetti
dmadisetti / Palindrome.java
Last active December 20, 2015 07:49
Quick hack to eval largest Palindrome in products of first 1000 numbers
public class Palindrome{
int firstNum = 999;
int secondNum = 100;
int result = 0;
int x = 0;
int holder;
public Palindrome(){
@dmadisetti
dmadisetti / DTutu
Last active December 30, 2015 03:49
Bit of Crypto. Nothing elegant, just a quick hack to decrypt a newspaper puzzle
// I normally use python for quick hacks like these- but javascript is so familiar at this point
var cipher = "ni xiph btffbo ytf iw liin azoho xip vho tf r fziro btffbo ytfr iw liin spf filofzoh fzvf imohazobg fzo aihbn norgijn fpfp".split('')
, i = cipher.length - 1
, dictionary = {}
, rank = ["E","T","A","O","I","N","S","H","R","D","L","C","U","M","W","F","G","Y","P","B","V","K","X","Q","J","Z"];
// based off of http://www.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html
// Probably find a way to sort as populating, but quicksort is so easy.. and I'm pretty lazy..
do{
@dmadisetti
dmadisetti / snake.css
Last active February 7, 2022 13:51
Snake snake snake snake
canvas{
height:300px;
width:300px;
}
@dmadisetti
dmadisetti / stepper_motor.ino
Last active August 29, 2015 13:57
Quick Arduino script to run a stepper motor
/*
*
* Full step motor procedure
*
*/
#include <elapsedMillis.h>
// Constants
#define STEP_PER_REVOLUTION 4 // Probably has more to do with current than steps, but will determine relationship at later point
@dmadisetti
dmadisetti / better_gravity.py
Last active August 29, 2015 13:58
The masses and coordinates of three spheres are as follows: 28 kg, x = 1.00 m, y = 2.50 m; 44 kg, x = -2.00 m, y = -1.75 m; 54 kg, x = 0.00 m, y= -0.50 m. What is the magnitude of the gravitational force on a 18 kg sphere located at the origin due to the other spheres?
import math
G = 6.67e-11
class Point:
def __init__(self,m,x,y):
self.m = m
self.x = x
self.y = y
% Second stab at matlab
function out = biSect(funct,hi,lo,x)
if hi < lo,
err = MException('MATLAB:ambiguousSyntax','Usage biSect(funct,hi,lo,x). hi cannot be lower rhar low.');
throw(err);
end
new = lo + (hi - lo)/2;
apprx = funct(new);
@dmadisetti
dmadisetti / newtonRaphson.m
Created September 15, 2014 18:49
newtonRaphson
% Third stab at matlab
function out = newtonRaphson(funct,old)
delta = 0.001;
y = funct(old);
m = (funct(old+delta)-y)/delta;
new = (m*old-y)/m;
apprx = funct(new);