Skip to content

Instantly share code, notes, and snippets.

View yriveiro's full-sized avatar
🧙‍♀️
Practicioner of Arcane and Forgotten Sorcery

Yago Riveiro yriveiro

🧙‍♀️
Practicioner of Arcane and Forgotten Sorcery
View GitHub Profile
@yriveiro
yriveiro / Linux Static IP
Created November 6, 2012 11:09 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()
import functools
class Foo(object):
def _cache(func):
@wraps(func)
def _cache_decorator(self, *args, **kwargs):
# Do stuff here
return func(self, *args, **kwargs)
return _cache_decorator

Solr.xml is broken?

Notice: This test was done with a fresh install of Solr either 4.4 or 4.5.

Solr 4.4

Create a collection

org.apache.solr.handler.ReplicationHandler$DirectoryFileStream; Exception while writing response for params: file=_h5kd.si&command=filecontent&checksum=true&wt=filestream&qt=/replication&generation=67128
java.io.FileNotFoundException: /ssd/solr/solrcloud-node/collections/collection-13_shard11_replica2/data/index.20131013191448349/_h5kd.si (No such file or directory)
@yriveiro
yriveiro / gist:7030222
Created October 17, 2013 18:51
Script to post json data to solr.
#!/bin/bash
for f in *.ready
do
status=$(curl --write-out %{http_code} --silent --output /dev/null http://192.168.20.101:8983/solr/statistics-$1/update? --data-binary @$f -H 'Content-type:application/json')
if [ $status -eq 200 ]
then
echo "Removing file $f"
rm -f $f
<?php
/**
* Dot notation for access multidimensional arrays.
*
* $dn = new DotNotation(['bar'=>['baz'=>['foo'=>true]]]);
*
* $value = $dn->get('bar.baz.foo'); // $value == true
*
* $dn->set('bar.baz.foo', false); // ['foo'=>false]
*
<?php
namespace Treffynnon;
/**
* A PHP class to access a PHP array via dot notation
* (Agavi http://www.agavi.org was the inspiration).
*
* This was hacked in to an existing codebase hence the
* global config array variable.
#!/usr/bin/python
import time
def fib(n):
if n < 2: return n
else: return fib(n - 1) + fib(n - 2)
def fast_fib(n, a, b):
if n == 0: return a