An introduction to curl using GitHub's API
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
if request.headers['Content-Type'] == 'application/json': | |
request_data = request.get_json() | |
user_id = request_data['user_id'] | |
msg = request_data['message'] | |
else: | |
user_id = request.form['user_id'] | |
msg = requ |
def exception_catcher(func): | |
def inner_func(*args, **kwargs): | |
try: | |
func(*args, **kwargs) | |
return True, None | |
except Exception as inst: | |
return False, inst | |
return inner_func | |
@exception_catcher |
require "net/http" | |
require "uri" | |
uri = URI.parse("http://google.com/") | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request["User-Agent"] = "My Ruby Script" | |
request["Accept"] = "*/*" |
Two Types of Socket:
UNIX Socket: Communicate between processes within a single local host. No networking capabilities
Berkeley Socket: Communicate between hosts via ports. Creating a Berkeley Socket creates a port and binds to it and the OS subsequently redirects all packages to that port to the bound process.
if you move 0 to index i there results in 2 cases: | |
i moved to 0: then the problem is reduced to n-2 (2 elements have swapped and are guaranteed to be in different positions) | |
i moved to somewhere else: problem is reduced to n-1 (n-1 slots left) |
document.getElementById("upload-files").value = ""; |
import simplejson as json | |
s = "{'username':'dfdsfdsf'}" #1 INCORRECT, uses '' for quotes in strings | |
s = '{"username":"dfdsfdsf"}' #2 CORRECT, uses "" for quotes in strings | |
j = json.loads(s) |
git checkout master | |
git checkout <target_branch> <paths> | |
ex: | |
git checkout cool_feature cool_new_file1 cool_new_file2 | |
git commit |
git diff > backup | |
git diff -w > changes (or whatever flag is needed) | |
git reset --hard | |
patch < changes (apply the changes listed in the file) |