Skip to content

Instantly share code, notes, and snippets.

View rodolfobandeira's full-sized avatar

Rodolfo rodolfobandeira

View GitHub Profile
@rodolfobandeira
rodolfobandeira / gist:4199c709d238a879e803aca9bbc4d380
Created October 31, 2019 12:55 — forked from philfreo/gist:7257723
Facebook Perl source code from 2005. When browsing around thefacebook.com in 2005 the server spit out some server-side source code rather than running it. I believe this was for their old graph feature that let you visualize the graph between all your friends. The filename is `mygraph.svgz` and contains some gems such as a commented out "zuck" d…
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@rodolfobandeira
rodolfobandeira / web-fonts-asset-pipeline.md
Created April 16, 2019 02:22 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@rodolfobandeira
rodolfobandeira / to_bool.md
Created April 7, 2019 13:45
Convert string to boolean in Ruby
  def to_bool(string)
    if string == true || string == 1 || string =~ (/(true|1)$/i)
      true
    else
      false
    end
  end
@rodolfobandeira
rodolfobandeira / character_set_and_collation.rb
Created March 10, 2019 04:04 — forked from tjh/character_set_and_collation.rb
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
import json
from sqlalchemy import *
engine = create_engine('CONNECTION STRING')
connection = engine.connect()
with open('config.json', 'r') as jsonFile:
jsonString = jsonFile.read()
config = json.loads(jsonString)
@rodolfobandeira
rodolfobandeira / rm_mysql.md
Created February 21, 2019 04:23 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

\xf0\x9f\x8e\xa7
\xe2\x8f\xb0
\xe2\x8f\xb3
\xf0\x9f\x8e\xa6
\xf0\x9f\x91\xbf
\xe2\x99\xa8
\xf0\x9f\x92\xa5
\xf0\x9f\x90\x98
\xf0\x9f\x9a\x98
\xf0\x9f\x92\xa4
@rodolfobandeira
rodolfobandeira / README.md
Created October 4, 2018 10:51 — forked from fasiha/README.md
clang-format.py for Vim integration with python3: from https://reviews.llvm.org/D23319

The current clang-format instructions are for Python2 Vim. If your Vim has only Python3 or if you load Python3 before Python2, those instructions won't work.

Therefore, (1) replace your clang-format.py with the file in this gist, from https://reviews.llvm.org/D23319. (2) Replace the relevant lines in .vimrc with:

map <C-K> :py3f ~/PATH/TO/clang-format.py<cr>
imap <C-K> <c-o>:py3f ~/PATH/TO/clang-format.py<cr>

N.B. Replace ~/PATH/TO with the actual path to clang-format.py.

@rodolfobandeira
rodolfobandeira / test-function-returning-string-cpp.cpp
Created August 12, 2018 02:55
Testing function returning string in C++
#include <iostream>
using namespace std;
namespace Foo {
class MyClass {
public:
static char *my_function(char *input) {
return input;
}
};
@rodolfobandeira
rodolfobandeira / Parser.h
Created August 11, 2018 00:53 — forked from PanagiotisPtr/Parser.h
Json Parser in C++ with Libcurl and Jsoncpp
#ifndef PARSER_H
#define PARSER_H
#include <iostream>
#include <string>
#include <curl/curl.h>
#include <jsoncpp/json/json.h>
#include <jsoncpp/json/reader.h>
#include <jsoncpp/json/writer.h>