Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@bindiego
bindiego / manacher
Created June 10, 2015 10:10
Longest Palindromic Substring - Manacher’s algorithm
// Transform S into T.
// For example, S = "abba", T = "^#a#b#b#a#$".
// ^ and $ signs are sentinels appended to each end to avoid bounds checking
string preProcess(string s) {
int n = s.length();
if (n == 0) return "^$";
string ret = "^";
for (int i = 0; i < n; i++)
ret += "#" + s.substr(i, 1);
@iamgreaser
iamgreaser / gist:cb893be7a6b658fd0fd1
Created July 12, 2014 00:10
NASM port of the Reality ADlib Tracker PLAYER.ASM playroutine + added standalone player
; 2014-07-12: Ported to NASM by @fanzyflani. Also contains a player!
; Stick a filename in here if you insist (or %define it elsewhere)
; (50Hz and 18.2Hz modules are detected and the IRQ0 timer adjusted accordingly)
%ifndef RAD_NO_DEFAULT_PLAYER
%ifndef RAD_MODULE_NAME
%define RAD_MODULE_NAME "ALLOYRUN.RAD"
%endif
%endif
; Or %define RAD_NO_DEFAULT_PLAYER in your code.
;
@Alex1Git
Alex1Git / sunrise sunset calculation
Last active December 20, 2018 09:00
sunrise sunset calculation / Berechnung Sonnenaufgang und Sonnenuntergang
# Formel von Dr. Roland Brodbeck, Calsky
# http://lexikon.astronomie.info/zeitgleichung/neu.html
# Uebertragung auf Python 3 von Alexander Klupp 2014-01-14
import math
pi2 = 2*math.pi
pi = math.pi
RAD = math.pi/180
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: