Skip to content

Instantly share code, notes, and snippets.

View leandro's full-sized avatar
🏠
Working from home

Leandro Camargo leandro

🏠
Working from home
View GitHub Profile
def create
@block_edit = false
debit_params = BankDebit.new(permitted_params[:bank_debit])
.attributes.symbolize_keys.merge(user_id: current_user.id)
Bank.transaction do
current_user.up_score!(1.3) if current_user.Potencial?
create_plot_debits!(debit_params)
create_debits!(debit_params)
redirect_to cash_path, notice: 'Lançamento realizado com sucesso'
@leandro
leandro / controller.rb
Last active March 19, 2019 14:45
Alterar nome do Admin mesmo com a senha em branco.
# frozen_string_literal: true
# Main Backoffice
class Backoffice::AdminsController < BackofficeController
before_action :set_admin, only: %i[edit update destroy]
after_action :verify_authorized, only: :new
after_action :verify_policy_scoped, only: :index
def index
@admins = policy_scope(Admin)
@leandro
leandro / gist:14d5477b2cfb15b22a7fedaa90201c69
Last active October 5, 2017 00:55 — forked from elebescond/gist:1433137
Generate a .pot template from a wordpress theme/codebase and update .po files
find . -iname "*.php" > /tmp/my_php_files.txt
# new template
xgettext --from-code=utf-8 -d my_dir -f /tmp/my_php_files.txt -o languages/my_theme.pot
# update template
xgettext --from-code=utf-8 -d my_dir -j -f /tmp/my_php_files.txt -o languages/my_theme.pot
# To update the already translated .po files and add new strings to them, run:
@leandro
leandro / displayselectors.jquery.js
Created May 19, 2012 11:54 — forked from dirceu/displayselectors.jquery.js
jQuery selectors for elements with display 'block' and 'inline'
(function($) {
$.extend($.expr[':'], {
inline: function(a) {
return $(a).css('display') == 'inline';
},
block: function(a) {
return $(a).css('display') == 'block';
}
});
})(jQuery);
@leandro
leandro / fullscreen.js
Created May 4, 2012 10:59 — forked from fnando/fullscreen.js
Working with fullscreen
var body = document.body;
if (body.requestFullScreen) {
body.requestFullScreen();
} else if (body.mozRequestFullScreen) {
body.mozRequestFullScreen();
} else if (body.webkitRequestFullScreen) {
body.webkitRequestFullScreen();
}
Index: sapi/cli/config.w32
===================================================================
--- sapi/cli/config.w32 (revision 308839)
+++ sapi/cli/config.w32 (working copy)
@@ -6,7 +6,8 @@
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
if (PHP_CLI == "yes") {
- SAPI('cli', 'php_cli.c', 'php.exe');
+ SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe');
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
var
a = [1,2,3,4,5],
b = [2,3],
subset_of = function(arr, arr_sub) { return new RegExp("-" + arr_sub.join('-') + "-").test("-" + arr.join('-') + "-"); };
console.log(subset_of(a, b)); // true
console.log(subset_of(a, b.reverse())); // false
#!/bin/sh
# Usage: unicorn_github
# Script used to start unicorn in GitHub staging and production environments.
# This is called primarily by god.
set -e
# configure GC settings
export RUBY_HEAP_MIN_SLOTS=800000
export RUBY_HEAP_FREE_MIN=100000
export RUBY_HEAP_SLOTS_INCREMENT=300000
@leandro
leandro / gemspec
Created May 13, 2010 17:47 — forked from defunkt/gemspec
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#