Skip to content

Instantly share code, notes, and snippets.

View proudlygeek's full-sized avatar
🍕

Gianluca Bargelli proudlygeek

🍕
View GitHub Profile
@proudlygeek
proudlygeek / nested.txt
Created January 19, 2022 09:30 — forked from alexey-milovidov/nested.txt
Example of Nested data type in ClickHouse.
:) CREATE TABLE test.nested (EventDate Date, UserID UInt64, Attrs Nested(Key String, Value String)) ENGINE = MergeTree(EventDate, UserID, 8192)
CREATE TABLE test.nested
(
EventDate Date,
UserID UInt64,
Attrs Nested(
Key String,
Value String)
) ENGINE = MergeTree(EventDate, UserID, 8192)
@proudlygeek
proudlygeek / golang-nuts.go
Created August 20, 2019 09:29 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
"""
exp ::= term | exp + term | exp - term
term ::= factor | factor * term | factor / term
factor ::= number | ( exp )
"""
class Calculator():
def __init__(self, tokens):
self._tokens = tokens
self._current = tokens[0]
#!/bin/bash
#
# Script to turn xdebug on and off
# Permission to copy and modify is granted under the MIT license
# Last revised 2014-03-07
# Mauro Maggi <maurotdo (at) gmail (dot) com>
PHP=$(which php)
XDEBUG=$($PHP -i | grep -i xdebug | grep -i enabled)
INI=$($PHP -i | grep "xdebug.ini")
<?hh
async function helloAfter($name, $timeout) {
// sleep asynchronously -- let other async functions do their job
await SleepWaitHandle::create($timeout * 1000000);
echo sprintf("hello %s\n", $name);
}
async function run() {
$joe = helloAfter('Joe', 3);

Coding challenge: cartified!

Hey JavaScript talents, here at namshi.com, we are looking for you! Submit this coding challenge to alex.nadalin@namshi.com and we'll get back to you as soon as possible!

Your task is to implement a basic shopping cart for a website, following these basic rules:

  • the cart needs to be implemented as an AngularJS service
  • the cart should be retrieved from the localStorage, where it's stored under the key cart
  • every time an action is performed on the cart, it should be persisted on the localStorage
  • the cart should only know about item IDs and their quantity
@proudlygeek
proudlygeek / chat.rb
Created August 25, 2012 10:02 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@proudlygeek
proudlygeek / Builder.php
Created July 6, 2012 11:19 — forked from mrflory/Builder.php
Twitter Bootstrap Twig Template for KnpMenuBundle in Symfony2
<?php
namespace Linkofy\CommonBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class Builder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@proudlygeek
proudlygeek / gist:2601418
Created May 5, 2012 10:34 — forked from lest/gist:1517325
Ruby 1.9.3 with readline and libyaml under rbenv
wget "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
tar xf readline-6.2.tar.gz
cd readline-6.2
./configure --prefix=$HOME/.rbenv/versions/1.9.3-p125
make -j 2
make install
cd ..
wget "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
tar xf yaml-0.1.4.tar.gz
@proudlygeek
proudlygeek / gist:2352357
Created April 10, 2012 15:53 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
brew install rbenv
brew install ruby-build
brew install --HEAD https://raw.github.com/jasoncodes/homebrew/rbenv-vars/Library/Formula/rbenv-vars.rb # https://github.com/mxcl/homebrew/pull/7891
brew install readline
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
exec $SHELL -i # reload the shell
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p125
rbenv global 1.9.3-p125
gem install bundler -v '~> 1.0.pre'
gem install git-up hitch gem-browse gem-ctags cheat awesome_print pry