Skip to content

Instantly share code, notes, and snippets.

import requests
from requests_oauthlib import OAuth1
import random
#API information
consumer_key = ""
consumer_secret = ""
token = ""
token_secret = ""
import random
randomfood = random.choice(open('food.txt').readlines())
print randomfood
@desg
desg / sweg.js
Created April 28, 2014 22:24
why does this return nothing?
function swag()
{
var req = new XMLHttpRequest();
req.open('GET', "http://www.google.com/", true);
req.send(null);
alert(req.responseText);
}
@desg
desg / gist:9858154
Last active August 29, 2015 13:57
how can I optimize 100k rounds 10-15 rolls per round
import random
from math import *
class player:
victories = 0
def set_levels(self, attack, strength, defense):
self.attack_level = attack
self.strength_level = strength
self.defense_level = defense
{"has_more_items":true,"items_html":"\n\n\n\n\n\n\n\n\n\n\n\n \u003cli class=\"js-stream-item stream-item stream-item \n\" data-item-id=\"31256852\" id=\"stream-item-user-31256852\" data-item-type=\"user\"\u003e\n \n\u003cdiv class=\"account js-actionable-user js-profile-popup-actionable \" data-screen-name=\"lorenzofertitta\" data-user-id=\"31256852\" data-feedback-token=\"\" data-impression-id=\"\" \u003e\n \n\n \n\u003cdiv class=\"user-actions btn-group not-following \" data-user-id=\"31256852\"\n data-screen-name=\"lorenzofertitta\" data-name=\"Lorenzo Fertitta\" data-protected=\"false\"\u003e\n\n\n\n \n\u003cdiv class=\"dropdown\"\u003e\n \u003cbutton type=\"button\" class=\"user-dropdown dropdown-toggle js-dropdown-toggle js-link js-tooltip btn plain-btn\" title=\"More user actions\"\u003e\n \u003cspan class=\"user-dropdown-icon Icon Icon--cogWithCaret Icon--large\"\u003e\u003cspan class=\"visuallyhidden\"\u003eUser Actions\u003c\/span\u003e\u003c\/span\u003e\n \u003c\/b
@desg
desg / gist:5572611
Created May 14, 2013 00:12
runescape combat
mage = 99.0
defence = 80.
hp = 81.0
prayer = 70.0
attack = 80.0
strength = 80.
rangeL = 1.0
baseLevel = .25 * ( defence + hp + (prayer/2))
wLevel = 13.0/40.0 * (attack + strength)
def inner(radius,width):
return (2 * 3.14158265 * radius * width) / 196935000
import requests
import time
def getReddit(subreddit):
baseurl = requests.get("http://reddit.com/r/%s/new/.json" % str(subreddit))
jsonData = baseurl.json()['data']['children']
return jsonData
@desg
desg / ping.gridlang
Last active December 11, 2015 02:39
@sweep
# assign n
PUSH 100
@L0
DUP
@desg
desg / yes.py
Created December 19, 2012 07:32
import requests
import json
i = requests.get('http://haruhichan.com/feed/feed.php?mode=json')
s = json.load(i)