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
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
var id = prompt("Введите ID пользователя", "0"); | |
var data = null; | |
var messages = {}; | |
messages[id] = []; | |
function getHistory() { | |
var viewer = $("<div></div>").attr({ | |
'id': 'viewer' |
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(Backbone){ | |
// Helper function to accessing nested JavaScript objects with string key | |
// via. http://stackoverflow.com/a/6491621 | |
var byString = function(object, stringKey) { | |
stringKey = stringKey.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties | |
stringKey = stringKey.replace(/^\./, ''); // strip a leading dot | |
var a = stringKey.split('.'); | |
while (a.length) { | |
var n = a.shift(); | |
if (n in object) { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Radio RPi</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css"/> | |
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> | |
</head> | |
<body> |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
(mc) ✘ ~/Tmp time python mc.py -a 192.168.1.31:11212 -n 10000 | |
Benchmarking pylibmc... | |
test_set: 9.433222 seconds | |
test_set_get: 18.527617 seconds | |
test_random_get: 35.192981 seconds | |
test_set_same: 10.686864 seconds | |
test_set_big_object (100 objects): 0.210625 seconds | |
test_set_get_big_object (100 objects): 0.411831 seconds | |
test_set_big_string (100 objects): 0.191070 seconds | |
test_set_get_big_string (100 objects): 0.373243 seconds |
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
# Simple localStorage function with Storage API fallback for chrome apps. | |
class BaseStorage | |
getItem: (key) -> | |
return sessionStorage.getItem(key) | |
setItem: (key, value) -> | |
data = {} | |
data[key] = value | |
chrome.storage.local.set 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
public func getSSID() -> String? { | |
let interfaces:CFArray! = CNCopySupportedInterfaces()?.takeUnretainedValue() | |
if interfaces == nil { return nil } | |
let if0:UnsafePointer<Void>? = CFArrayGetValueAtIndex(interfaces, 0) | |
if if0 == nil { return nil } | |
let interfaceName:CFStringRef = unsafeBitCast(if0!, CFStringRef.self) | |
let dicRef:NSDictionary! = CNCopyCurrentNetworkInfo(interfaceName)?.takeUnretainedValue().__conversion() | |
if dicRef == nil { return nil } | |
let ssidObj:AnyObject? = dicRef[kCNNetworkInfoKeySSID] | |
if ssidObj == nil { return nil } |
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
# file: .ebextensions/02-commands.config | |
container_commands: | |
00001-docker-privileged: | |
command: 'sed -i "s/docker run -d/docker run --privileged -d/" /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh' |
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
import httplib | |
import mimetypes | |
import base64 | |
def post_multipart(host, selector, fields, files, headers): | |
""" | |
Post fields and files to an http host as multipart/form-data. | |
fields is a sequence of (name, value) elements for regular form fields. | |
files is a sequence of (name, filename, value) elements for data to be uploaded as files | |
Return the server's response page. |
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
""" | |
requirements: | |
- requests http://docs.python-requests.org/en/latest/ | |
- requests-toolbelt https://toolbelt.readthedocs.org/en/latest/ | |
pip install requests requests-toolbelt | |
""" | |
import requests |
OlderNewer