Skip to content

Instantly share code, notes, and snippets.

View johndel's full-sized avatar
🖖

John Deliyiannis johndel

🖖
View GitHub Profile
@johndel
johndel / Very early refactoring
Created November 4, 2011 17:49
Refactor number one
if(document.getElementById('currentyear').value <= 2013) {
if(document.getElementById('currentmonth').value == 12) {
document.getElementById('currentmonth').value=13;
}
else if(document.getElementById('currentmonth').value == 11) {
document.getElementById('currentmonth').value=12;
}
else if(document.getElementById('currentmonth').value == 10) {
document.getElementById('currentmonth').value=11;
@johndel
johndel / devise.gr.yml
Last active November 4, 2017 14:25
Greek i18n for devise
gr:
errors:
messages:
expired: "έχει λήξει, παρακαλούμε ζητήστε νέο"
not_found: "δεν βρέθηκε"
already_confirmed: "έχει ήδη επιβεβαιωθεί, παρακαλούμε δοκιμάστε να ξανασυνδεθείτε"
not_locked: "δεν είναι κλειδωμένο"
not_saved:
one: ""
other: ""
@johndel
johndel / pages_controller.rb
Last active December 10, 2015 11:39
Subscribe after it makes green the test. Some refactoring?
def subscribe
subscriber = Subscriber.where(email: params[:newsletter_email]).first
if subscriber
if subscriber.approval != "Approved"
NewsletterMailer.send_code_confirm(subscriber.email, subscriber.code_confirmation).deliver
redirect_to root_url, notice: "Σας εστάλη ένα email επιβεβαίωσης."
else
redirect_to root_url, notice: "Το email σας υπάρχει ήδη στη λίστα μας. Σας ευχαριστούμε για την εγγραφή!"
end
else
@johndel
johndel / crtmpd_init.sh
Last active December 10, 2015 16:08
Start, restart and stop crtmpdserver :) My Edition! I love it.
#!/bin/bash
case $1 in
start)
echo "Starting crtmpd...";
cd /root/crtmp/;exec ./crtmpserver ./configs/mine.lua &
echo "crtmpd started.";
sleep 2;
echo $(lsof -t -i :1935) > /var/run/crtmpd.pid;
echo $(lsof -t -i :1935);
require 'rubygems'
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'rspec/autorun'
upstream unicorn {
server unix:/tmp/unicorn.escortamazons.sock fail_timeout=0;
}
server {
server_name escortamazons.com;
rewrite ^ $scheme://www.escortamazons.com$request_uri permanent;
# permanent sends a 301 redirect whereas redirect sends a 302 temporary redirect
# $scheme uses http or https accordingly
}
@johndel
johndel / omniauth_helpers.rb
Created February 4, 2013 13:51
Omniauth Helper File
def omniauth_facebook
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
:provider => 'facebook',
:uid => '1234567',
:info => {
:nickname => 'jbloggs',
:email => '[email protected]',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
@johndel
johndel / vcr.rb
Created February 4, 2013 13:53
vcr
VCR.configure do |c|
c.ignore_localhost = true
c.cassette_library_dir = Rails.root.join("spec", "vcr")
c.hook_into :webmock
end
RSpec.configure do |c|
c.treat_symbols_as_metadata_keys_with_true_values = true
c.around(:each, :vcr) do |example|
name = example.metadata[:full_description].split(/\s+/, 2).join("/").underscore.gsub(/[^\w\/]+/, "_")
@johndel
johndel / gist:4706913
Created February 4, 2013 14:10
Simple controller test
...
describe "GET 'delete'" do
before :each do
@upload = create(:upload)
end
it "deletes the upload" do
expect{
delete :destroy, id: @upload
}.to change(Upload, :count).by(-1)
@johndel
johndel / mine.lua
Created February 9, 2013 00:10
crtmp mine.lua
configuration=
{
daemon=false,
pathSeparator="/",
logAppenders=
{
{
name="console appender",
type="coloredConsole",