Skip to content

Instantly share code, notes, and snippets.

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

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
@nrk
nrk / gemfile_changelog.rb
Created November 22, 2012 09:30 — forked from thbar/gemfile_changelog.rb
Get Changelogs for outdated gems in Gemfile
#!/usr/bin/env ruby
def changelog_for_gem(gem)
changelogs = `bundle exec gem contents #{gem}`.lines.grep(/history|changelog|news/i)
if changelogs.empty?
puts "No changelog found for gem #{gem}"
return nil
end
@nrk
nrk / redis_hash_copy.php
Created November 8, 2011 10:50
Use Redis scripting to copy an hash to a new key.
<?php
require 'autoload.php';
$redis = new Predis\Client('tcp://127.0.0.1', 'dev');
// *** NOTE *** Lua's unpack() has a limit on the size of the table imposed by
// the number of Lua stack slots that a C function can use. This value is defined
// by LUAI_MAXCSTACK in luaconf.h and for Redis is set to 8000, which translates
// to an hash of 4000 elements since HGETALL returns a list that interleaves field
@nrk
nrk / redis_app.lua
Created August 17, 2010 08:06
Redis + mercury + luapages (tiny example)
require 'luarocks.require'
require 'mercury'
require 'redis'
module('redis_app', package.seeall, mercury.application)
local templates = {
index = [[
<html>
@nrk
nrk / zpop.lua
Created December 28, 2010 15:10
Implementation of ZPOP with redis-lua + CAS transactions
require 'luarocks.require'
require 'redis'
-- See "WATCH explained" from http://redis.io/topics/transactions
--[[
./redis-cli ZADD zset 1 a
./redis-cli ZADD zset 2 b
./redis-cli ZADD zset 3 c
]]
<?php
require __DIR__.'/../autoload.php';
function group_keys_by_slot(\Predis\Cluster\StrategyInterface $strategy, array $keys) {
$keysBySlot = [];
foreach ($keys as $key) {
$slot = $strategy->getSlotByKey($key);
@nrk
nrk / Dockerfile
Created June 28, 2016 12:52
Modify UID and GID of the "git" user in the official gogs/gogs Docker image.
FROM gogs/gogs:latest
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && apk --no-cache add shadow
RUN usermod -u 1100 git && groupmod -g 1100 git
prefvmx.allVMMemoryLimit = "3000" ; Limite massimo di RAM host utilizzabile dalle VM (in megabyte, es. 3GB)
prefvmx.minVmMemPct = "100" ; Usa solo la RAM host per allocare memoria guest
prefvmx.useRecommendedLockedMemSize = "TRUE" ; Prealloca tutta la memoria del guest all'avvio della VM
mainMem.useNamedFile = "FALSE" ; Disabilita i file .vmem per lo swap di memoria guest
@nrk
nrk / MasterSlaveClusterInitializer.php
Created February 15, 2013 11:47
This is an example of a cluster (client-side sharding) of "virtual" nodes each one configured in a master/slave replication setup.
<?php
namespace Nrk\Predis;
use Nrk\Predis\Connection\MasterSlaveWrapperConnection;
use Predis\Cluster\Distribution\HashRing;
use Predis\Connection\PredisCluster;
use Predis\Option\ClientOptions;
class MasterSlaveClusterInitializer
@nrk
nrk / gist:3417659
Created August 21, 2012 17:37 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@nrk
nrk / output.txt
Created April 4, 2012 13:51
Graph of the instant bitrate of a video stream using spark
adaniele@psamathe ~/Desktop % ./video-bitrate.rb 20120315_15s.mp4 | spark
▃▆▃▂▃▆█▆▅▇▆▅▇▆▆▁