Skip to content

Instantly share code, notes, and snippets.

View gustin's full-sized avatar
🦁
Happy

gustin gustin

🦁
Happy
View GitHub Profile
@gustin
gustin / rename.sh
Created April 10, 2019 01:08 — forked from nerdyworm/rename.sh
rename a phoenix project
#!/bin/bash
set -e
CURRENT_NAME="CurentName"
CURRENT_OTP="current_name"
NEW_NAME="NewName"
NEW_OTP="new_name"
@gustin
gustin / regexCheatsheet.js
Created January 15, 2019 14:39 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@gustin
gustin / Elixir
Created June 28, 2017 14:36 — forked from ashleyconnor/Elixir
Elixir Socket Example
defmodule SocketPlayground do
def listen(port) do
listen(port, &handler/1)
end
def listen(port, handler) do
IO.puts "listen"
Socket.TCP.listen!(port, packet: :line)
|> accept(handler)
end
@gustin
gustin / gist:02160d959a39ed4cf6f9d200115bc35b
Created December 19, 2016 16:57 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
When starting a project that includes refinerycms-blog:
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
module MyApp
module Database
def connect(pool_size = nil, reap_time = nil)
return unless defined? ActiveRecord::Base
config = Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = reap_time || ENV['AR_DB_REAP_FREQ'] || 10 # seconds
config['pool'] = pool_size || ENV['AR_DB_POOL'] || 5
ActiveRecord::Base.establish_connection(config)
end
launchers:
integration:
command: "rspec testing/integration"
headless:
command: "HEADLESS=1 rspec testing/integration"
src_files:
- testing/integration/*.rb
- app/webroot/js/src/global.js
test_page: app/webroot/js/SpecRunner.html
launch_in_dev:
@gustin
gustin / 0_reuse_code.js
Created January 20, 2014 03:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gustin
gustin / Gemfile
Created September 12, 2013 01:59 — forked from peterhellberg/Gemfile
source :rubygems
gem "sinatra", "~> 1.3.2"
group :test do
gem "minitest", "~> 2.10"
gem "rack-test", "~> 0.6.1"
gem "capybara", "~> 1.1"
gem "capybara-webkit", "~> 0.11"
gem "capybara_minitest_spec", "~> 0.2"