Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Here's a couple of metaboxes that I've recently created using this system
*/
$subpostings = redrokk_metabox_class::getInstance('subpostings', array(
'title' => '(optional) Subscription for Postings',
'description' => "As an optional feature, you have a complete api at your disposal which will allow you the ability to offer and manage member posts. In addition to these settings, you may need to create the associated pages for accepting posts from your frontend.",
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
language = 'en'
article = ARGV[0] ||
begin
print 'What do you need to know? : '
URI::encode gets.chomp

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

# Chained comparisons in Ruby
# inspired by http://coffeescript.org/#comparisons
# as well as http://refactormycode.com/codes/1284
[:<, :>, :<=, :>=].each do |operator|
[Float, Fixnum, Rational, Comparable].each do |klass|
klass.class_eval do
alias_method "_#{operator}", operator
define_method operator do |rhs|
send("_#{operator}", rhs) && rhs
double x = 0;
do
{
Console.WriteLine("the num plz");
x = double.Parse(Console.ReadLine());
if (x > 0)
{
Console.WriteLine(x);
}
else if( x > 0 )

http://guides.rubyonrails.org/getting_started.html

Rails Guides Getting Started Notes

rails new -h see all app builder switches

File/Folder Purpose

app/ Contains the controllers, models, views and assets for your application. You'll focus on this folder for the remainder of this guide.
config/ Configure your application's runtime rules, routes, database, and more. This is covered in more detail in Configuring Rails Applications
config.ru Rack configuration for Rack based servers used to start the application.

  1. don't use self.method name, just put it in class << self
  2. don't use get_property, use the property name directly get_ and set_ is considered noise in ruby
  3. always add () in function definition with parameters
  4. you should always specify your rescued excpetion class
  5. there are a lot of cryptic lines with implicit logic like flatten[1]
  6. be consistent with methods names "_by(id)"
class SimpleGit
def self.git(method_name, cmd = nil)
define_method(method_name) do |args|
if cmd
git("#{cmd} #{args}")
else
git("#{method_name} #{args}")
end
end
end
@emad-elsaid
emad-elsaid / stack.js
Last active July 29, 2016 17:14 — forked from khaled0fares/stack.js
Stack implementation in JS using class and constructor
'use strict'
let Stack = function(max){
if(typeof max != 'number' || max == NaN){
throw new Error(max + ' should be a number');
}
var Store = [],
top = 0,
empty = function() { return top === 0; },
@emad-elsaid
emad-elsaid / natega.rb
Last active July 12, 2017 19:40 — forked from a7madM/natega.rb
require 'uri'
require 'net/http'
require 'pp'
require 'json'
seat_number = 427_300 # write start seat number
count = 10
(seat_number..seat_number + count).each do |seat|
url = URI('http://natega.youm7.com/Home/GetResultStage1/')