Skip to content

Instantly share code, notes, and snippets.

View hopewise's full-sized avatar

Samir Sabri hopewise

View GitHub Profile
@amouillard
amouillard / app\Http\Middleware\Cors.php
Created November 19, 2016 22:52
CORS middleware for Laravel 5.3
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
public function handle($request, Closure $next)
{
@zulhfreelancer
zulhfreelancer / starts_with.md
Created November 17, 2016 07:34
Rails ActiveRecord: How to find all items that starts with something?
Model.where("table_column LIKE :prefix", prefix: "#{keyword}%")
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@piger
piger / tmux-cssh.zsh
Last active November 20, 2023 10:51
tmux-cssh
#!/usr/bin/env zsh
# tmux cluster ssh + knife support
# Daniel Kertesz <[email protected]>
#
# Add basic hosts completion to zsh by running:
# compdef _hosts tmux-cssh
set -e
autoload colors; colors
@webdev1001
webdev1001 / gist:e848abef8064c55c2f6443a282f75651
Last active February 18, 2021 21:51
Array values in the parameter to `Gem.paths=` are deprecated.
Array values in the parameter to `Gem.paths=` are deprecated.
Please use a String or nil.
An Array (...) was passed in from bin/rails:3:in `load'
Solution
========
https://github.com/rubygems/rubygems/issues/1551
If you came to this issue by googling the error specified in the description of this issue, you should know that it has already been fixed in spring-1.6.4 and all you need to do is to update to latest spring and regenerate binstubs, like this:
@hendricius
hendricius / 01_add_cors.config.yaml
Created June 27, 2016 17:24 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk (Rails)
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@bearded-avenger
bearded-avenger / devise.rb
Last active January 11, 2022 17:04
Rails - SSO - WordPress - Authenticating against a WordPress install from a Rails site using oAuth
config.omniauth :wordpress_hosted, ENV['SSO_KEY'], ENV['SSO_SECRET'],
strategy_class: OmniAuth::Strategies::WordpressHosted,
client_options: { site: ENV['SSO_URL'] }
@mgwidmann
mgwidmann / twitter_stream.ex
Last active May 28, 2024 08:28
Infinite Streams with Elixir
# Elixir has lazily evaluated enumerable objects that allow you
# to work with enumerable objects like lists either only as needed
# or infinitely.
# Start up iex to play around
$ iex
# Typical enumeration is done eagerly where the result is computed ASAP
iex> Enum.map(1..10, fn i -> i * 2 end)
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@danpecher
danpecher / rubymine-debugging.md
Last active August 19, 2019 13:02
How to enable RubyMine debugging when using pow and rails

First create a .powenv file and add:

export RUBY_DEBUG_PORT=1234
export POW_WORKERS=1

Add the following gems to your Gemfile:

gem 'ruby-debug-ide'