Skip to content

Instantly share code, notes, and snippets.

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

Aleksandar Popovic alekpopovic

🏠
Working from home
View GitHub Profile
@alekpopovic
alekpopovic / Procfile.development
Created March 12, 2016 12:35 — forked from madhums/Procfile.development
foreman and thinking sphinx
sphinx: bundle exec rake thinking_sphinx:run_in_foreground RAILS_ENV=development --trace
# This is an example for a rails app to share model content to facebook and twitter with a scheduler and delayed_job_active_record
# My main model is called quote.rb
# Gemfile
gem 'omniauth-twitter', '~> 1.2'
gem 'omniauth-facebook', '~> 3.0'
gem 'validates_timeliness', '~> 4.0'
gem 'twitter', '~> 5.15'
gem 'koala', '~> 2.2'
First off you need to modify application/config/rest.php
```
$config['rest_default_format'] = 'json';
```
This will ensure that when your api call is made the server will return json without an additional segment.
You must then create an api controller that will return your codeigniter model in the correct format for Ember.js
```
<?php
require(APPPATH.'/libraries/REST_Controller.php');
@alekpopovic
alekpopovic / random_search.rb
Created March 17, 2016 16:55
Random Search Algorithm
########################################################################################################################
#
# Random Search Algorithm
#
# Input: NumIterations, ProblemSize, SearchSpace
# Output: Best
#
# BestSolution ← ∅;
# foreach iteration i ∈ NumIterations do
# search_candidate i ← RandomSolution(ProblemSize, SearchSpace);
@alekpopovic
alekpopovic / pty_example.rb
Created March 18, 2016 12:55
PTY EExample
require 'pty'
cmd = "blender -b mball.blend -o //renders/ -F JPEG -x 1 -f 1"
begin
PTY.spawn( cmd ) do |stdout, stdin, pid|
begin
# Do stuff with the output here. Just printing to show it works
stdout.each { |line| print line }
rescue Errno::EIO
puts "Errno:EIO error, but this probably just means " +
"that the process has finished giving output"
@alekpopovic
alekpopovic / digital_ocean_setup.md
Created March 30, 2016 19:32 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions
@alekpopovic
alekpopovic / routes.rb
Created April 4, 2016 20:53 — forked from ThomasHambach/routes.rb
Rails redirect to default locale
Rails.application.routes.draw do
scope "/:locale" do
# blablabla..
end
root to: "welcome#index"
get '/:locale' => 'welcome#index', :as => 'locale_root'
end
@alekpopovic
alekpopovic / backbone.api.facebook.js
Created April 11, 2016 19:08 — forked from tracend/backbone.api.facebook.js
[DEPRECATED] Backbone.js APIs: Facebook Project moved: http://github.com/backbone-api/facebook
/* Backbone API: Facebook
* Source: https://github.com/backbone-api/facebook
*
* Created by Makis Tracend (@tracend)
* Distributed through [Makesites.org](http://makesites.org)
* Released under the [MIT license](http://makesites.org/licenses/MIT)
*/
// Assuming that Facebook JS lib is loaded...
if( window.FB ) (function(_, Backbone) {
@alekpopovic
alekpopovic / add.js
Created April 13, 2016 09:52 — forked from simenbrekken/add.js
Backbone.js form submission
define([
'backbone',
'underscore',
'project/views/form'
], function(Backbone, _, ProjectFormView) {
var View = Backbone.View.extend({
events: {
'submit form': 'submit'
},
@alekpopovic
alekpopovic / install_elixir.md
Created April 19, 2016 21:31 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then kerl and exenv are your best friends.