Skip to content

Instantly share code, notes, and snippets.

View sturmer's full-sized avatar
🌈

Gianluca Ciccarelli sturmer

🌈
View GitHub Profile
@sturmer
sturmer / piping.ex
Last active March 5, 2021 11:35
Elixir snippet for blog post
iex> [1, [2], 3] |> List.flatten() |> Enum.map(fn x -> x * 2 end)
[2, 4, 6]
@sturmer
sturmer / init-const-no-closure.js
Last active January 25, 2018 12:26
Initialize variable without callback (but give up const-ness)
#!/usr/local/bin/node
// Test: Is it faster to initialize a const via callback, or to use let and then an if statement?
// Solution 2: no callback (but also, no const)
const TIMES = 1e6;
const time = process.hrtime(); // returns [seconds, nanoseconds]
for (let i = 0; i < TIMES; i++) {
let x = null;
// Imagine some more processing here...
if (2 + 1 === 4) {
@sturmer
sturmer / gitconfig.ini
Created August 31, 2016 10:54 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
# Put this in your ~/.gitconfig or ~/.config/git/config
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName>
[user]
name = Your Full Name
email = your@email.tld
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
st = status

Keybase proof

I hereby claim:

  • I am sturmer on github.
  • I am sturmer (https://keybase.io/sturmer) on keybase.
  • I have a public key ASC0DR6PLPYHibIbjeGUb39QbzQCja1uLkB7Xbu40-E7cQo

To claim this, I am signing this object:

@sturmer
sturmer / rt.cpp
Created February 1, 2014 16:55
Rotten Tomatoes API access with POCO libraries
// Access Rotten Tomatoes API
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/StreamCopier.h"
#include "Poco/Exception.h"
#include <string>
@sturmer
sturmer / Shapes.cc
Created December 22, 2013 13:56
Example of std::none_of
#include <iostream>
#include <vector>
#include <algorithm>
using std::cout;
using std::vector;
using std::none_of;
struct Shape {
Shape() {}
@sturmer
sturmer / anyof.cpp
Created December 22, 2013 13:12
Example of std::any_of
#include <algorithm>
#include <iostream>
#include <vector>
using std::vector;
using std::all_of;
using std::cout;
enum Continent {
EUROPE, ASIA, AMERICA, AFRICA, AUSTRALIA
};
@sturmer
sturmer / allof.cpp
Created December 22, 2013 13:03
Example of std::all_of
#include <algorithm>
#include <iostream>
#include <vector>
using std::vector;
using std::all_of;
using std::cout;
enum Continent {
EUROPE, ASIA, AMERICA, AFRICA, AUSTRALIA
};
@sturmer
sturmer / Makefile
Created December 11, 2013 18:29
Functors versus lambdas
# Yeah, I am bad at writing Makefiles on the fly :(
all: example_functors.cpp example_lambdas.cpp
g++ -std=c++0x -g -Wall -Werror example_functors.cpp -o ef
g++ -std=c++0x -g -Wall -Werror example_lambdas.cpp -o el
@sturmer
sturmer / simple_filter.cpp
Created December 3, 2013 18:56
Silly example with lambdas
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <fstream>
using std::function;
using std::string;