Skip to content

Instantly share code, notes, and snippets.

@Loupax
Loupax / queue_processing.go
Last active September 15, 2022 10:46 — forked from valsteen/queue_processing.go
Queue processing
/*
This demonstrates a task scheduling loop where tasks can send back other tasks to the queue.
Program input: a nested list of items that can either be integers, or nested slices:
- when it's an integer, wait for 25 - value seconds
- when it's a slice, wait for len(slice) seconds, then put back each item in the queue to be processed next
waiting time simulates some processing, on which a concurrency limit is applied ( both waiting times share the same
limit ). pushing back to the queue should not be blocking.
@Loupax
Loupax / Style Checkbox with CSS using Label.html
Last active April 30, 2018 13:42
Use a hidden checkbox, label and styles to style the checkbox. A fork (and minor clean up) of https://gist.github.com/592332
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label {
This file has been truncated, but you can view the full file.
ETYMOLOGY.
(Supplied by a Late Consumptive Usher to a Grammar School)
The pale Usher--threadbare in coat, heart, body, and brain; I see him
now. He was ever dusting his old lexicons and grammars, with a queer
handkerchief, mockingly embellished with all the gay flags of all
the known nations of the world. He loved to dust his old grammars; it
somehow mildly reminded him of his mortality.
<?php
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
define('NO_RECREATE_DB', (bool) getenv('NO_RECREATE_DB') ?: false);
define('CLEAR_CACHE', (bool) getenv('CLEAR_CACHE') ?: true);
define('RECREATE_DB', (bool) getenv('RECREATE_DB') ?: false);
@Loupax
Loupax / greek-flag.js
Created June 30, 2016 21:24
The Greek flag in a console.log
console.log(
"%c %c %c \n" +
"%c %c %c %c \n" +
"%c %c \n" +
"%c %c %c %c \n" +
"%c %c %c \n" +
"%c \n" +
"%c \n" +
"%c \n" +
"%c \n",
@Loupax
Loupax / node-and-npm-in-30-seconds.sh
Created October 26, 2015 08:39 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@Loupax
Loupax / assetPath.js
Last active June 20, 2020 18:28 — forked from cramhead/assetPath.js
A function that returns the path of the provided package asset
var getAssetPath = function getAssetPath(packageName, assetPath) {
assetPath = assetPath || '';
var meteor_root = Npm.require('fs').realpathSync(process.cwd() + '/../');
var assets_folder = meteor_root + '/server/assets/packages/'+packageName.replace(':','_')+'/'+assetPath;
return assets_folder;
};
#!/bin/bash
tail "$@" | awk '
{matched=0}
/INFO:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE
/NOTICE:/ {matched=1; print "\033[0;36m" $0 "\033[0m"} # CYAN
/WARNING:/ {matched=1; print "\033[0;34m" $0 "\033[0m"} # BLUE
/ERROR:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED
/ALERT:/ {matched=1; print "\033[0;35m" $0 "\033[0m"} # PURPLE
matched==0 {print "\033[0;33m" $0 "\033[0m"} # YELLOW