This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Single News | |
*/ | |
?> | |
<?php | |
// Switching if projects or if news | |
$proj='projects'; | |
$catid=-1; | |
foreach(get_categories() as $category) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Server to forward all HTTP | |
server { | |
# replace a.b.c.d with IP | |
listen a.b.c.d:80; | |
location / { | |
if ($host ~* ^(example\.com|www\.example\.com)$ ) { | |
rewrite ^/(.*)$ https://example.com/$1 permanent; | |
} | |
# Nonstandard code 444 closes the connection without sending any headers | |
return 444; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Give Me Post Params | |
* | |
* Check if params are JSON encoded (acording to content-type header) and if so decode and return | |
* if not simply return the POST array so | |
* | |
* @access public | |
* @return array | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getScript(base_url + "vapor.js?" + new Date().getTime()) | |
.fail(function(jqxhr, settings, exception) { | |
fallback(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_record" | |
require "ffaker" | |
class Post < ActiveRecord::Base | |
end | |
class Generator | |
SQL_TYPE_TO_DATA_MAPPING = { | |
:varchar => /^varchar\((\d+)\)/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before 'foreman:restart', 'foreman:thin_stop' | |
namespace :foreman do | |
desc "Stop thin servers" | |
task :thin_stop, :roles => :app do | |
rake = fetch(:rake, 'rake') | |
rails_env = fetch(:rails_env, 'production') | |
run "cd '#{current_path}' && #{rake} thin:stop RAILS_ENV=#{rails_env}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProtectedResource < ActiveResource::Base | |
# since the gateway uses oauth2 every call needs to be authenticated, | |
# so the token for is needed | |
class << self | |
attr_accessor :token_string | |
end | |
# setup the headers for oauth2 | |
def self.headers | |
{ 'authorization' => "Bearer #{token_string}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Run JSHint if there is a jshint.json present in the project | |
autocmd FileType javascript map <leader>h :call RunJSHint()<cr> | |
function! RunJSHint(...) | |
let to_hint_file = match(expand("%"), '\(.js\)$') != -1 | |
let options_file = "jshint.json" | |
if filereadable(options_file) && to_hint_file | |
echo to_hint_file | |
:w | |
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NeverSave < ActiveRecord::Base | |
before_create :dont_create_me | |
def dont_create_me | |
false | |
end | |
end | |
NeverSave.save # => false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NeverSave < ActiveRecord::Base | |
validate :dont_validate_me | |
def dont_validate_me | |
errors.add(:base, "haha I will never validate") | |
end | |
end | |
NeverSave.valid? # => false |