Skip to content

Instantly share code, notes, and snippets.

View benaneesh's full-sized avatar

Ben Aneesh benaneesh

View GitHub Profile
@benaneesh
benaneesh / .irbrc
Created July 5, 2013 16:22
settings for better rails console
# make sure you git pull and bundle before this
# save in ~/.irbrc (make a new one if it doesnt exist)
if ENV['RAILS_ENV']
require 'rubygems'
require 'hirb'
require 'wirble'
require "pp"
# sublime preferences
{
"update_check": false,
"bold_folder_labels": true,
"fade_fold_buttons": false,
"line_padding_bottom": 1,
"line_padding_top": 1,
"highlight_line": true,
"caret_style": "wide",
"tab_size": 2,
color_list = Tags::Color.all.map {|n| n.name}
hash = Hash[color_list.map.with_index.to_a]
missing_ids = []
Style.joins(:taggings).find_each do |tags|
id = tags.id
tags.taggings.each do |t|
begin
name = TagValue.find(t.tag_value_id).name
if color_list.include? name
@benaneesh
benaneesh / gist:7775590
Created December 3, 2013 19:09
Edit product in stylekick
javascript:(function() {window.location=window.location.toString().replace("stylekick.com/","stylekick.com/admin/");})()
# first update
yum -y update
# install dev tools
yum -y groupinstall "Development Tools"
# insall rvm for ruby
\curl -L https://get.rvm.io | bash -s stable
@benaneesh
benaneesh / Push.swift
Last active October 5, 2017 20:26
Push notification in swift (iOS)
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
// notification
if let options = launchOptions {
let notificationPayload: NSDictionary = options[UIApplicationLaunchOptionsRemoteNotificationKey] as NSDictionary
// do somehting with the notifications
}
// Register for Push Notitications, if running iOS 8
@benaneesh
benaneesh / Log.m
Created January 29, 2015 21:16
Suppress printlns in production
#ifdef DEBUG
#define NSLog(...) /* suppress NSLog when in release mode */
#endif
//
// GooglePlaces.swift
//
// Created by Kirby Shabaga on 9/8/14.
// ------------------------------------------------------------------------------------------
// Ref: https://developers.google.com/places/documentation/search#PlaceSearchRequests
//
// Example search
//
@benaneesh
benaneesh / ClassName.swift
Created February 4, 2015 19:40
Getting NSCoding on swift
import UIKit
class ClassName: NSObject, NSCoding {
var myVariable: String?
override init() {}
required init(coder aDecoder: NSCoder) {
myVariable = aDecoder.decodeObjectForKey("myVariable") as? String
}
@benaneesh
benaneesh / fbLogin.swift
Created March 30, 2015 01:21
IOS FaceBook login with Parse
// MARK: - Login Button Pressed
@IBAction func loginButtonPressed(sender: AnyObject) {
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
let permissions = ["user_about_me", "public_profile", "email", "user_relationships", "user_birthday", "user_location"]
PFFacebookUtils.logInWithPermissions(permissions, { (user: PFUser!, error: NSError!) -> Void in
if user == nil {
if (error == nil) {
println("User cancelled FB login")
}else{
println("FB login error: \(error)")