Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
nelsonsar / ls_find_size.sh
Last active December 19, 2015 08:59
Listing files that have a :filename: and have more than 1b of size in GNU/Linux
#!/bin/bash
ls -lhart `find -name ':filename' -size +1b`
@nelsonsar
nelsonsar / php_tuples.php
Created July 6, 2013 19:09
PHP tuples. With PHP we can make Python tuples using an array and the list function, this is not built-in, but it's a way to make code more readable!
<?php
function return_fake_tuples()
{
return array(
'apple', 'banana'
);
}
list($apple, $banana) = return_fake_tuples();
@nelsonsar
nelsonsar / composite_dataset_phpunit.php
Created July 6, 2013 20:49
Using more than one PHPUnit fixture in one test.
<?php
class DummyTest extends YourDatabaseTestClass
{
protected function getDataSet()
{
$firstDataSet = $this->createXMLDataSet(__DIR__ . '/fixtures/first_fixture.xml');
$secondDataSet = $this->createXMLDataSet(__DIR__ . '/fixtures/second_fixture.xml');
$dataSets = array(
@nelsonsar
nelsonsar / update_ctags.sh
Last active December 19, 2015 15:28
This is a script for update ctags and put a tags.{git_base_dir} on the folder that you specify. It will also search for a .srclist in your home folder, for PHP developers is nice to put your include_path for PEAR.Thanks to @henriquemoody for bash support!
#!/bin/bash
ctags -R --exclude=".git" \
-h '.php' \
--languages=-javascript,sql \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cfiv \
--regex-PHP="/(abstract)?\s+class\s+([^ ]+)/\2/c/" \
--regex-PHP="/(static|abstract|public |protected|private)\s+(final\s+)?function\s+(\&\s+)?([^ (]+)/\4/f/" \
@nelsonsar
nelsonsar / .vimrc
Created July 11, 2013 14:52
This is my .vimrc file. It will get update since UpdateCTags function for some reason breaks in some cases...
"mark trailing whitespaces
hi link localWhitespaceError Error
au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
au Syntax * syn match localWhitespaceError / \+\ze\t/ display
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
"change tabs for 4 spaces
set tabstop=4
@nelsonsar
nelsonsar / git_diff_same_file_different_branches
Created July 11, 2013 14:55
Making git diff for the same file but in different branches
git diff $FIRST_BRANCH_NAME:$FILE_NAME $SECOND_BRANCH_NAME:$FILE_NAME
@nelsonsar
nelsonsar / main.pp
Created July 28, 2013 20:42
Puppet stage feature
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
stage { 'preinstall':
before => Stage['main']
}
class apt_get_update {
exec { 'apt-get -y update': }
}
@nelsonsar
nelsonsar / apache.pp
Created July 30, 2013 16:36
Your own apache virtual host configuration with puppet
class apache {
package { "apache2":
ensure => present
}
service { "apache2":
enable => true,
ensure => running,
require => Package["apache2"]
}
@nelsonsar
nelsonsar / political_values.md
Last active December 21, 2015 22:08
Polical values

Political Values

Radicalism 91.25
Socialism 31.25
Tenderness 56.25

These scores indicate that you are a progressive; this is the political profile one might associate with a university professor. It appears that you are skeptical towards religion, and have a pragmatic attitude towards humanity in general.

@nelsonsar
nelsonsar / good_commit_message.txt
Created August 29, 2013 22:05
Good commit message template. This was extracted from http://blog.dynamic50.com/2009/11/26/moving-your-git-repos-and-all-branches-to-a-new-remote-repository/ and ALL credits should go for him.
Here’s a model Git commit message:
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.