Skip to content

Instantly share code, notes, and snippets.

View sauron's full-sized avatar

Pablo Barrios sauron

  • San Miguel de Tucumán, Argentina
View GitHub Profile
@lorisleiva
lorisleiva / toSqlWithBindings.php
Last active November 15, 2023 08:54
A little macro to get the SQL from a query builder without the annoying "?".
<?php
use Illuminate\Database\Eloquent\Builder;
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
$this->getBindings()
);
{
"Twill input regular": {
"scope": "php,blade",
"prefix": "tinput",
"body": [
"@formField('input', [",
" 'name' => '${1:name}',",
" 'label' => '${1:label}',",
"])"
@thewhatsupguy
thewhatsupguy / largefilesubuntulinux.sh
Created July 4, 2015 14:14
Find Large Files in Ubuntu Linux
#Files larger than 10 MB in current Directory
find . -xdev -size +10M -exec ls -lh {} \;
#Files larger than 1GB in current Directory
find . -xdev -size +1G -exec ls -lh {} \;
#Files larger than 1GB from Root
sudo find / -xdev -size +1G -exec ls -lh {} \;
#Files larger than 1GB in folder folder1
@sauron
sauron / christmass_tree.rb
Last active December 31, 2015 21:09
What it takes to make a scalable Christmas tree in Ruby?
#Simple tree that will look as an arrow :D
height = 20
((1..height).to_a+[6]*height.div(5)).map do |i|
puts ('*'*i*2).center(80)
end
#Simple tree that look more like a doodle christmas tree
height = 20
(
@mislav
mislav / fat-logfiles.sh
Last active December 22, 2018 19:56
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@mattetti
mattetti / rack_example.ru
Created December 8, 2011 13:58
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
#1 download mingw-w32-1.0-bin_i686-darwin_20110429.tar.bz2
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/mingw-w32-1.0-bin_i686-darwin_20110429.tar.bz2/download
#2 extract ~/mingw/w32
#3 add ~/mingw/w32/bin to $PATH
#4 rake-compiler cross-ruby HOST=i686-w32-mingw32
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')