Skip to content

Instantly share code, notes, and snippets.

View niklas88's full-sized avatar

Niklas Schnelle niklas88

View GitHub Profile
@niklas88
niklas88 / listrec.c
Last active December 10, 2015 21:08
Example of tail recursive functions for manipulating a singly linked list, inspired by https://plus.google.com/u/0/111049168280159033135/posts/2zMqrkydzJi both gcc -O3 and clang -O3 compile all used recursions to loops therefor the stack does not overflow. Unlike the example linked in the post above this is valid C99 code (no bool, true, false) …
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
typedef struct node {
struct node* next;
int val;
} node;
SYSTEM_THREAD(ENABLED);
#include "HttpClient/HttpClient.h"
#include "PowerShield/PowerShield.h"
/**
* Declaring the variables.
*/
HttpClient http;
const long sleep_interval = 60*5;
package main
import (
"flag"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"net/http"
"os"
)
#include <stdint.h>
#include <stdio.h>
#include <zmq.h>
#include <assert.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if(argc < 3) {
fprintf(stderr, "Usage %s: <xpublish_url> <xsubsriber_url>\n", argv[0]);
exit(1);
PREFIX fb: <http://rdf.freebase.com/ns/>
SELECT DISTINCT ?cityname ?countryname ?popcount ?latitude ?longitude WHERE {
?citytype fb:type.object.name "City/Town/Village"@en .
?city fb:type.object.type ?citytype .
?city fb:type.object.name ?cityname .
?city fb:location.location.containedby ?country .
?city fb:location.statistical_region.population ?population .
?population fb:measurement_unit.dated_integer.number ?popcount .
#include <iostream>
#include <experimental/filesystem>
#include <fstream>
namespace fs = std::experimental::filesystem;
int main() {
fs::path path = u8"猫.txt";
std::cout << "path = " << path << std::endl;
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
std::vector<std::string_view> split_no_strcpy(std::string_view orig, const char sep) {
std::vector<std::string_view> result;
if (orig.size() > 0) {
size_t from = 0;
size_t sepIndex = orig.find(sep);
#include <chrono>
#include <iostream>
#include <algorithm>
#include <array>
int main(int argc, char** argv) {
std::array<int, 13> arr = {12, 5, 7, 9, 2, 2, 33, 24, 1, 8, 0, 3, 77};
auto start = std::chrono::high_resolution_clock::now();
std::sort(arr.begin(), arr.end());
@niklas88
niklas88 / min-byte-rnn.py
Last active March 23, 2018 12:54 — forked from karpathy/min-char-rnn.py
Karpathy's original minimal char rnn + Python 3 + bytes directly instead of chars
#!/usr/bin/env python3
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
import sys
import time
# data I/O
" Show tabs, End-of-Line and Trailing spaces
set listchars=tab:▸\ ,eol:¬,trail:~
" So the background is transparent for the above characters
highlight Normal ctermbg=none
highlight NonText ctermbg=none
" Whitespace at end of line in red
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/