Skip to content

Instantly share code, notes, and snippets.

View aichholzer's full-sized avatar
🚴‍♂️
Improving...

Stefan Aichholzer aichholzer

🚴‍♂️
Improving...
  • Same as you...
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aichholzer on github.
  • I am safetrip (https://keybase.io/safetrip) on keybase.
  • I have a public key ASAe8kSBgNpTrhWMn91T-IVFUb10kS1rJ6G_K11Rl9EGRgo

To claim this, I am signing this object:

@aichholzer
aichholzer / curl.md
Created November 4, 2021 01:48 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@aichholzer
aichholzer / copydyn.js
Last active July 20, 2020 00:33
Copy data from one DynamoDB table to another.
#!/usr/bin/env node
/* eslint no-console: 0 */
const AWS = require('aws-sdk');
AWS.config.update({ region: 'ap-southeast-2' });
const db = new AWS.DynamoDB.DocumentClient();
const [, , from, to] = [...process.argv];
if (!from || !to) {
console.error('\n 💥 The "from" and "to" arguments are required.');
@aichholzer
aichholzer / int2ip.js
Created July 7, 2020 04:01 — forked from jppommet/int2ip.js
javascript conversion from ip address to long integer and vice versa
function int2ip (ipInt) {
return ( (ipInt>>>24) +'.' + (ipInt>>16 & 255) +'.' + (ipInt>>8 & 255) +'.' + (ipInt & 255) );
}
@aichholzer
aichholzer / for.js
Last active July 14, 2023 21:37
Validación de cédulas y similares (Algoritmo de Luhn)
const ced = '0931811087';
let [suma, mul, chars] = [0, 1, ced.length];
for (let index = 0; index < chars; index += 1) {
let num = ced[index] * mul;
suma += num - (num > 9) * 9;
mul = 1 << index % 2;
}
if ((suma % 10 === 0) && (suma > 0)) {
@aichholzer
aichholzer / client.js
Created May 2, 2018 05:02
Gzip - client/server
const http = require('http');
const { readFile } = require('fs');
const { gzip } = require('zlib');
const { promisify } = require('util');
const run = async () => {
try {
const data = await promisify(readFile)('./menu.json');
const req = http.request({
method: 'POST',
@aichholzer
aichholzer / clean.js
Created February 7, 2018 21:59
Remove all empty properties from an object, recursively.
const sample = {
a: 'Hello',
b: '', // Will be removed
c: null,
d: {
a: 1,
b: '', // Will be removed
c: 3,
d: {
a: 1,
@aichholzer
aichholzer / jquery.animator.js
Last active November 9, 2017 03:31
Element animator for jQuery
/**
* Element fadeIn plugin for jQuery.
* @author Stefan Aichholzer <https://github.com/aichholzer>
* @param options -Object defining the animation's end result.
*
* {
* opacity: 1,
* marginBottom: 5,
* duration: 50
* }
@aichholzer
aichholzer / promiseMap.js
Created November 3, 2017 10:49
Promise maps
const heartbeats = [1, 2, 3].map((value) => Promise.resolve({ id: value, date: +new Date() }));
Promise.all(heartbeats).then((values) => {
console.log(values.map((value) => !value.date ? null : {
id: value.id,
name: 'location',
heartbeat: value.date
}).filter(v => v).sort()
);
});
@aichholzer
aichholzer / bash_profile.sh
Last active September 22, 2017 04:43
Shell
export PS1="\n\[\033[1;102m\]\[\033[1;30m\] \A \[\033[1;103m\]\[\033[1;30m\] \u \[\033[0;107m\]\[\033[1;30m\] \w \[\033[0m\] \[\`if [ \$? != 0 ]; then echo 😠 ' '; fi \`\]"
alias ls='ls -lhaG'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias gm="grunt nodemon"
alias gish="ssh -T git@github.com"