Skip to content

Instantly share code, notes, and snippets.

View rmariuzzo's full-sized avatar
🤒
Fighting a cancer.

Rubens Mariuzzo rmariuzzo

🤒
Fighting a cancer.
View GitHub Profile
@rmariuzzo
rmariuzzo / sprintf.js
Created February 2, 2014 01:16
Simple and minimal `sprintf` function in JavaScript.
function sprintf(format) {
var args = Array.prototype.slice.call(arguments, 1);
var i = 0;
return format.replace(/%s/g, function() {
return args[i++];
});
}
@rmariuzzo
rmariuzzo / keyframes-mixin.scss
Created November 14, 2013 19:29
Keyframes. Create a named animation sequence that can be applied to elements later.
/**
* Keyframes.
* Create a named animation sequence that can be applied to elements later.
*
* Usage:
* @include keyframes(fly) {
* from {
* transform: rotate(0deg);
* }
* to {
@rmariuzzo
rmariuzzo / pngcrushall.sh
Created November 11, 2013 03:02
Crush all PNG files in current directory.
#!/bin/sh
for file in *.png ; do pngcrush "$file" "${file%.png}-crushed.png" && mv "${file%.png}-crushed.png" "$file" ; done
@rmariuzzo
rmariuzzo / CustomValidator.php
Created October 8, 2013 04:38
A simple Laravel 4 validator that ensure the field under validation must match the format defined according to the `Carbon\Carbon::createFromFormat` method.
<?php
use Carbon\Carbon;
use Illuminate\Validation\Validator;
class CustomValidator extends Validator {
# carbon_date_format #
public function validateCarbonDateFormat($attribute, $value, $parameters)
@rmariuzzo
rmariuzzo / compile-js.sh
Last active December 21, 2015 14:39
A simple NodeJS script to watch for changes in a specific less and js file. When changes detected then bash script will be executed for to compile less files and to uglify js scripts.
clear
curdir="${0%/*}"
uglifyjs -v \
$curdir/jquery/jquery.js \
$curdir/twbs/js/bootstrap.js \
$curdir/superfish/superfish.js \
$curdir/site/js/site.js \
-o $curdir/../../js/app.js \
-m
echo 'JS files compiled successfully!'
@rmariuzzo
rmariuzzo / listen-illuminate-query.xml
Created July 28, 2013 23:27
Sublime Text 2 snippet to listen for illuminate query on Laravel 4. Useful for profiling generated SQL queries.
<snippet>
<content><![CDATA[
Event::listen('illuminate.query', function($sql) {dd($sql);});
]]></content>
<tabTrigger>sql</tabTrigger>
<scope>source.php</scope>
</snippet>
@rmariuzzo
rmariuzzo / chrome.css
Created July 13, 2013 17:07
Google Chrome button styles when "webpage is not available".
button {
border: 1px solid rgba(0, 0, 0, 0.25);
border-radius: 2px;
color: #444;
margin: 0px 5px;
min-height: 29px;
min-width: 65px;
-webkit-user-select: none;
padding: 8px 13px;
/* iOS does not support linear-gradient without a prefix. */
@rmariuzzo
rmariuzzo / Preferences.sublime-settings.json
Created March 8, 2013 13:36
Personal `Preferences.sublime-settings` file for Sublime Text 2.
{
"color_scheme": "Packages/Color Scheme - Default/Cobalt.tmTheme",
"detect_slow_plugins": false,
"dictionary": "Packages/Language - English/en_US.dic",
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"ignored_words":
/// <summary>
/// Return the full name of an entity.
/// </summary>
public String FullName()
{
get
{
return String.Join(" ", new String[] { this.FirstName, this.MiddleName, this.LastName, this.SecondLastName });
}
}
@rmariuzzo
rmariuzzo / TwitterBootstrapColumnsInRazor.cs
Created February 25, 2013 13:12
Create columns using Twitter Bootstrap in Razor with C#.
for (var i = 0; i < list.Count; i++)
{
var first = i == 0;
var last = i == list.Count - 1;
var current = i + 1;
var previous = i;
if (first || previous % 3 == 0)
{
@Html.Raw("<div class=\"row\">");