Skip to content

Instantly share code, notes, and snippets.

View winfried-van-loon's full-sized avatar
🎯
Focusing

Winfried winfried-van-loon

🎯
Focusing
View GitHub Profile
@nimatrueway
nimatrueway / mendix-downloader.sh
Last active August 30, 2023 20:44
Mendix downloader for Linux/macOS/Unix
#!/bin/bash
#
# Description:
# downloads mendix of the specified version and places it in `$HOME/.mendix/{{specified-version}}`
#
# Usage:
# mendix-downloader.sh {{specify-the-desired-version}}
# (e.g. mendix-downloader.sh 7.23.7.55882)
#
MXBUILD_VERSION=$1
@kaz3w
kaz3w / resolve_meta_release_lts_check_error.sh
Created May 12, 2019 08:46
Ubuntu 18. Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
sudo rm /var/lib/ubuntu-release-upgrader/release-upgrade-available
sudo /usr/lib/ubuntu-release-upgrader/release-upgrade-motd
@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@WebReflection
WebReflection / i18n.js
Created October 22, 2017 15:58
i18n in 10 lines of code
function i18n(template) {
for (var
info = i18n.db[i18n.locale][template.join('\x01')],
out = [info.t[0]],
i = 1, length = info.t.length; i < length; i++
) out[i] = arguments[1 + info.v[i - 1]] + info.t[i];
return out.join('');
}
i18n.locale = 'en';
i18n.db = {};
@thomasmichaelwallace
thomasmichaelwallace / unique.js
Created August 1, 2017 16:20
Getting unique values using sets in ES6.
// with arrays
const dupArr = [1, 1, 2, 3, 1];
const uniArr = [...(new Set(dupArr))];
// [1, 2, 3]
// with objects on a key.
const dupObj = [{ id: 1, value: 'a' }, { id: 2, value: 'b' }, { id: 1, value: 'c' }];
const uniKeys = [...(new Set(dupObj.map(({ id }) => id)))];
// [ '1', '2' ]
@Reder
Reder / os_x_install.sh
Last active June 15, 2019 01:05
[Mac Installation script] Use Homebrew to install dev tools and apps. Not tested yet. #Mac
#!/bin/sh
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# homebrew taps
brew tap caskroom/cask
brew tap caskroom/versions
brew tap caskroom/fonts
# homebrew apps
@alairock
alairock / generator.php
Last active February 3, 2017 19:31
Using a Generator in PHP. Helpful when you need to work on hundreds....thousands....millions of records. Don't load them all into memory all at once. Work on them one at a time!
<?php
$usersQuery = \App\User::query();
$usersQuery->where('type', '=', 'client');
foreach(generate($usersQuery) as $user) {
// Do something with that user
}
@devlead
devlead / git-random-tip.ps1
Last active November 9, 2015 15:08
PowerShell scrips that displays random GIT tips
(irm https://raw.githubusercontent.com/git-tips/tips/master/tips.json)|sort {random}|select -First 1|% {"$($_.title)`r`n$($_.tip)" }
@iolson
iolson / .env.example
Created September 17, 2015 22:14
GitLab CI Laravel 5.1.*
DB_HOST=mysql
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
@DavidWells
DavidWells / check-if-april-fools-day.js
Created April 2, 2015 00:03
Check if it is April fools day
/* Check if it is april fools day */
var aprilFools = {
month: 3,
date: 1
}
function isItAprilFoolDay() {
var now = new Date();
return (now.getMonth() == aprilFools.month && now.getDate() == aprilFools.date);
}