This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Testing syntax highlighting. | |
import requests | |
r=float(requests.get("http://www.nnums.com/api/get/CCCCCC.n").text) | |
print 'I love strings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From http://stackoverflow.com/questions/3677400/making-a-http-post-request-using-arduino | |
IPAddress server(10,0,0,138); | |
String PostData = "someDataToPost"; | |
if (client.connect(server, 80)) { | |
client.println("POST /Api/AddParking/3 HTTP/1.1"); | |
client.println("Host: 10.0.0.138"); | |
client.println("User-Agent: Arduino/1.0"); | |
client.println("Connection: close"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from lxml import html | |
#Get the page source as altered by the browser | |
browser = webdriver.Firefox() | |
url='http://www.amazon.com/Levi-Magic-Pants-Douglas-Bradshaw-ebook/dp/B0086K9JI0/' | |
browser.get(url) | |
html_source = browser.page_source | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pip install watchdog | |
#sudo apt-get install xvkbd | |
#!/bin/bash | |
watchmedo shell-command \ | |
--patterns="*.rst" \ | |
--ignore-pattern='_build/*' \ | |
--recursive \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses jquery | |
$.ajax({ | |
type: "POST", | |
url: "{% url 'attachment-object-coupling' project.slug %}", | |
data: { | |
attachment: attachments.attr("id"), // attachment instance_id | |
object: objects.attr("id"), // object instance_id | |
csrfmiddlewaretoken: '{{ csrf_token }}' // if not configured to include token in every post | |
}, | |
success: function(data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils import timezone | |
import pytz | |
pytz_tz = pytz.timezone('America/Chicago') | |
# wrong -- The direct approach leads to somewhat random time offsets between timezones. | |
adt = timezone.datetime(year=2016, month=1, day=6, tzinfo=pytz_tz) | |
# correct: Localize a naive datetime. | |
ndt = timezone.datetime(year=2016, month=1, day=6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function query() { | |
var | |
// HN is done with very unsemantic classes. | |
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')), | |
query_list = Array.prototype.slice.call(arguments), | |
shown = 0, total = job_list.length; | |
// Traverses up the dom stack trying to find a match of a specific class | |
function up_to(node, klass) { | |
if (node.classList.contains(klass)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: %load_ext autoreload | |
In [2]: %autoreload 2 | |
In [3]: from core.courses import questions | |
In [4]: questions.meaning_of_life() | |
Out[4]: 42 | |
In [5]: "Rewriting method" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get html collection of images: | |
var imgs = document.getElementsByTagName('img') | |
// Convert to array | |
imgs = Array.from(imgs) | |
// Map to urls | |
var urls = imgs.map(img => img.src) | |
// Copy to clipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encrypt file | |
gpg -c --cipher-algo AES256 private-file.txt | |
# Decrypt it | |
gpg private-file.txt.gpg | |
# !!Don't forget the passphrase!! |
OlderNewer