Skip to content

Instantly share code, notes, and snippets.

View nicolashohm's full-sized avatar

Nicolas Hohm nicolashohm

View GitHub Profile
@nicolashohm
nicolashohm / assert.sas
Last active October 28, 2023 14:22
Assert methods like they exist in test frameworks for SAS
%macro assertEquals(expected, actual, message);
%if &expected ne &actual %then %do;
%put ERROR: Failed asserting that &actual is equal to &expected - &message;
%end;
%mend;
* Asserts that the value returned by the query in actual is equals to the expectation;
%macro assertSqlEquals(expected, query, message);
proc sql noprint;
&query;
@nicolashohm
nicolashohm / composer.json
Last active June 11, 2018 12:45
The Empty Framework
{
"name": "nickel715/empty",
"description": "",
"license": "MIT",
"authors": [
{ "name": "Nicolas Hohm" }
],
"autoload": {
"files": ["empty.php"]
}
@nicolashohm
nicolashohm / Vagrantfile
Created June 3, 2017 20:22
Vagrant bento centos with npm
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@nicolashohm
nicolashohm / ffs_in_file.c
Created August 5, 2016 22:10
find first set in file
#include<stdio.h>
int main(int argc, char *argv[]) {
printf("Start reading...\n");
FILE *fp = fopen(argv[1], "r");
int res = 0, buff = 0, ffs = 0, pos = 0;
while (fread(&buff, sizeof(int), 1, fp) == 1) {
ffs = __builtin_ffs(buff);

Keybase proof

I hereby claim:

  • I am nickel715 on github.
  • I am nickel715 (https://keybase.io/nickel715) on keybase.
  • I have a public key ASCKuMD23F9FALILCKmy0uaCGrkHVL76UXCNVboD96FTKwo

To claim this, I am signing this object:

@nicolashohm
nicolashohm / clipboard.js
Created June 5, 2016 10:23
Copy custom data into the clipboard on copy event
document.addEventListener('copy', function(e) {
e.clipboardData.setData('text/plain', 'Foo');
e.preventDefault();
})
@nicolashohm
nicolashohm / bookmarklet.js
Created January 23, 2016 09:42
Bookmarklet to vote up question and answer on stackoverflow.com
javascript:(function(){
var a=document.getElementsByClassName('answer')[0];
a.getElementsByClassName('vote-up-off')[0].click();
var b=document.getElementsByClassName('question')[0];
b.getElementsByClassName('vote-up-off')[0].click();
}());
@nicolashohm
nicolashohm / gist:1f1a865138bc173514a4
Last active November 10, 2015 19:07
Stop uglifying the javascript of freifunkMUC/meshviewer
--- a/tasks/build.js
+++ b/tasks/build.js
@@ -82,7 +82,7 @@ module.exports = function(grunt) {
mainConfigFile: "app.js",
include: "../app",
wrap: true,
- optimize: "uglify",
+ optimize: "none",
out: "build/app.js"
}
@nicolashohm
nicolashohm / gist:75b7a3a42202f9f861fa
Last active November 4, 2015 20:56
Copy all lines from test not starting with "a" to withoutA
$ cat test
sdf
asdf
sdf
ert
aert
fgh
$ grep -v '^a' test > withoutA
$ cat withoutA
sdf
@nicolashohm
nicolashohm / gist:56277015a3bc10d4bb7e
Last active August 29, 2015 14:15
check array keys in PHP
$array = [
'foo' => null,
'bar' => '',
];
var_dump(isset($array['foo'])); // false
var_dump(empty($array['foo'])); // true
var_dump(array_key_exists('foo', $array)); // true
var_dump($array['foo'] === NULL); // true
var_dump($array['foo'] == NULL); // true