Skip to content

Instantly share code, notes, and snippets.

View nrk's full-sized avatar
🤔
はい、猫のように見えます。

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
namespace Mono.Linq.Expressions {
public static class PredicateBuilder {
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@nrk
nrk / fizzbuzz_generators.php
Last active July 16, 2023 16:37
FizzBuzz'ing in PHP, just for the heck of it.
<?php
// Same approach as of `fizzbuzz_short.php` but with some generators love so you
// can fizzbuzz all you want without blowing up you memory. HOW GREAT IS IT?
$fbrange = function ($start, $stop) {
if ($start > 0) {
for ($n = $start; $n < $stop; $n++) {
yield (($f=!($n%3))|($b=!($n%5)))?($f?'Fizz':'').($b?'Buzz':''):"$n";
}
@nrk
nrk / RedisPublishHandler.php
Created August 24, 2011 14:01
A simple handler for Monolog that publishes log entries to Redis channels.
<?php
namespace Nrk\Monolog\Handler;
use Predis\Client;
use Monolog\Logger;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\AbstractProcessingHandler;
/**
@nrk
nrk / win32_map_network_drive.rb
Created September 7, 2008 19:22
How to map a network share in Windows with Ruby & Win32API
require 'Win32API'
module NetworkDrive
CONNECT_UPDATE_PROFILE = 0x1
RESOURCE_CONNECTED = 0x1
RESOURCE_GLOBALNET = 0x2
RESOURCETYPE_DISK = 0x1
RESOURCEDISPLAYTYPE_SHARE = 0x3
RESOURCEUSAGE_CONNECTABLE = 0x1
@nrk
nrk / gist:31175
Created December 2, 2008 16:53
A function in Lua similar to PHP's print_r
-- A function in Lua similar to PHP's print_r, from http://luanet.net/lua/function/print_r
function print_r ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
@nrk
nrk / .deferred-command-pipeline
Last active September 22, 2020 21:00
Proof of concept for deferred command pipelines in Predis v2.0 (dev).
We couldn’t find that file to show.
@nrk
nrk / Random bytes, ints, UUIDs in PHP.md
Created May 11, 2016 16:15 — forked from tom--/Random bytes, ints, UUIDs in PHP.md
PHP random bytes, integers and UUIDs

Random bytes, ints, UUIDs in PHP

Simple and safe random getters to copy-paste

string randomBytes( int $length )

int randomInt ( int $min , int $max )

string randomUuid ( void )
@nrk
nrk / instructions.md
Created February 17, 2019 16:04 — forked from douglasmiranda/instructions.md
Add email to Keybase.io PGP Key (Public Key)

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret &gt; keybase-private.key
@nrk
nrk / keybase.md
Created February 17, 2019 16:04 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key