Skip to content

Instantly share code, notes, and snippets.

View tsolar's full-sized avatar

Tomás Solar Castro tsolar

  • Santiago, Chile
View GitHub Profile
@tsolar
tsolar / active_for_authentication.rb
Last active June 9, 2016 16:56
Permitir sólo a algunos emails acceder a la app en Rails
# from http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Authenticatable
# Poner en el modelo User
def special_condition_is_valid?
permitted_emails = [
# Poner acá los emails permitidos para acceder
"email1@example.com",
"email2@example.com"
]
if permitted_emails.include?(self.email)
@tsolar
tsolar / rename-branch.sh
Created May 10, 2016 18:08 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@tsolar
tsolar / fonts.conf
Created February 23, 2016 21:59
arial font
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font" >
<edit mode="assign" name="rgba" >
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="lcdfilter">
@tsolar
tsolar / pg_dump_restore.sh
Created February 23, 2016 19:29
dump & restore postgres db
#!/bin/bash
pg_dump -i -h <hostname> -p 5432 -U <user> -F c -b -v -f /tmp/<filename>.sql <database_name>
pg_restore -i -h <local_hostname> -p 5432 -U <user> -d <database_name> -v /tmp/<filename>.sql
/etc/hosts
/var/lib/mysql/
/etc/nginx/sites-available
/etc/nginx/nginx.conf # maybe?
@tsolar
tsolar / BaseModel.php
Last active August 29, 2015 14:06
Base Model for Laravel 4
<?php
use LaravelBook\Ardent\Ardent; // it can be Eloquent too
class BaseModel extends Ardent {
protected $_name;
public static function optionList($attribute = 'name') {
$model = static::getModel();
@tsolar
tsolar / laravel-subdirectory.conf
Last active February 27, 2024 03:36
Laravel in subdirectory nginx example
server {
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
sendfile on;
send_timeout 300s;
# Port that the web server will listen on.
#listen 80;
@tsolar
tsolar / whitespace-fix.php
Last active August 29, 2015 14:03
Whitespace fix for php
<?php
/**
* this is a fix mainly for wordpress, to prevent xml error
*
* this solution is from http://www.vichaunter.com/desarrollo-web/solucion-para-error-line-2-column-6-xml-declaration-allowed-start-document-wordpress
*
*/
function ___wejns_wp_whitespace_fix($input) {
/* valid content-type? */
@tsolar
tsolar / install_mongo_php.sh
Last active January 3, 2016 06:59
install mongo extension for PHP
apt-get install php5-dev php-pear make mongodb
pecl install mongo
echo 'extension=mongo.so' > /etc/php5/mods-available/mongodb.ini
cat /etc/php5/mods-available/mongodb.ini
ln -s /etc/php5/mods-available/mongodb.ini /etc/php5/fpm/conf.d/20-mongodb.ini
service php5-fpm restart
server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}