Skip to content

Instantly share code, notes, and snippets.

View bbrodriges's full-sized avatar

bbrodriges bbrodriges

View GitHub Profile
@bbrodriges
bbrodriges / gist:7416842
Created November 11, 2013 17:20
Custom 404 on tumbl.com
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
/* Custom 404 */
$(document).ready(function() {
var page_404 = $("section.post h2 a:contains(Not Found)").length;
if (page_404) {
// you can do magic...
}
});
</script>
@bbrodriges
bbrodriges / autopu.sh
Created December 30, 2013 05:44
Автоматическая генерация отчетов покрытия кода тестами по номеру задачи в коммитах.
# шаблон конфига phpunit.xml
XMLDUMMY="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<phpunit bootstrap=\"work/tests/TestHelper.php\"
backupGlobals=\"false\"
backupStaticAttributes=\"false\"
colors=\"true\"
processIsolation=\"true\"
verbose=\"true\">
@bbrodriges
bbrodriges / sentences.php
Last active September 21, 2024 15:42
Simple PHP function to split text by given number of sentences with given length each.
/**
* Simple PHP function to split text by given number of sentences with given length each.
*
* @param string $long_string String of text
* @param int $max_length Maximum length of each sentence. Default: 150
* @param int $max_sentences Maximum number of sentences to return. Default: 10
* @param string $encoding Encoding of input string. Default: 'UTF-8'
*
* @return array
*/

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@bbrodriges
bbrodriges / gearman_monitor.sh
Created April 10, 2014 09:31
Oneliner to continuously monitor Gearman queue
while(true) do ((echo "status"; sleep 0.1) | nc gearman.local 4730); printf "\033[4A"; sleep 3; done
@bbrodriges
bbrodriges / Vagrantfile
Created August 29, 2014 07:48
My default Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
VM_NAME = "Rainicorn"
IP_ADDRESS = "192.168.100.3"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
@bbrodriges
bbrodriges / params_insert.js
Created April 8, 2015 07:30
Ввернуть параметры в GET
$(function() {
function insertParams(params) {
var url_params = window.location.search.substring(1).split('&');
var url_params_obj = {};
// пересобираем GET параметры в объект
for (var p = 0; p < url_params.length; p++) {
var url_param = url_params[p].split('=');
url_params_obj[url_param[0]] = url_param[1];
@bbrodriges
bbrodriges / Vagrantfile
Created April 17, 2015 21:08
Vagrantfile to install 3 Ubuntu Trusty VMs with public DHCP network and rust from host archive
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
['bmo', 'finn', 'jake'].each do |name|
config.vm.define "#{name}" do |node|
node.vm.box = "ubuntu/trusty64"
@bbrodriges
bbrodriges / rust-python-cffi.md
Created February 4, 2016 20:29 — forked from seanjensengrey/rust-python-cffi.md
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI

Based on http://harkablog.com/calling-rust-from-c-and-python.html which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
@bbrodriges
bbrodriges / api.go
Created March 2, 2016 15:40 — forked from peterhellberg/api.go
A tiny example API written in Go using Martini and Redigo
package main
import (
"flag"
"fmt"
"net/http"
"github.com/codegangsta/martini"
"github.com/garyburd/redigo/redis"
"github.com/martini-contrib/render"