Skip to content

Instantly share code, notes, and snippets.

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
@peterdalle
peterdalle / robots.txt
Created December 3, 2016 15:18
Robots.txt that makes sure Facebook and Twitter can crawl images on your site.
# Disallow everything.
User-agent: *
Disallow: /
# Certain social media sites are whitelisted to allow crawlers to access page markup when links to /images are shared.
User-agent: Twitterbot
Allow: /images
User-agent: facebookexternalhit
Allow: /images

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
require 'securerandom'
class NameGenerator
LEFT = [
"admiring",
"adoring",
"affectionate",
"agitated",
"amazing",
"angry",
@njvitto
njvitto / deploy.rake
Created April 11, 2010 16:56 — forked from RSpace/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@humanzz
humanzz / Mercator.rb
Created October 29, 2008 13:07
Ruby implementation for GMercatorProjection
# This is a port of the javascript code found in the following link
#http://groups.google.com/group/Google-Maps-API/browse_thread/thread/a45947d72c27cc73
class Mercator
#offset is defined at zoom level 21 which means that this Mercator is valid for 21 zoom levels
OFFSET = 268435456
RADIUS = OFFSET / Math::PI
def self.lng_to_x(lng, zoom)
(OFFSET + RADIUS * lng * Math::PI / 180).to_i >> (21 - zoom)
@odrobnik
odrobnik / gist:1845108
Created February 16, 2012 14:10
ImageIO versus UIImageJPEGRepresentation
// UIImageJPEGRepresentation
NSData *data = UIImageJPEGRepresentation(tileImage, 0.71);
[data writeToURL:cacheURL atomically:YES];
// ImageIO
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>
@MartinMoizard
MartinMoizard / gist:6537467
Created September 12, 2013 13:37
Category on UIViewController: recursive function to present a modal View Controller anywhere in the application. Example: [self.window.rootViewController presentViewControllerFromVisibleViewController:myViewController]; Works with application using only UINavigationController and modal views. Can be enhanced to handle UITabBarController or other…
- (void)presentViewControllerFromVisibleViewController:(UIViewController *)viewControllerToPresent
{
if ([self isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *)self;
[navController.topViewController presentViewControllerFromVisibleViewController:viewControllerToPresent];
} else if (self.presentedViewController) {
[self.presentedViewController presentViewControllerFromVisibleViewController:viewControllerToPresent];
} else {
[self presentModalViewController:viewControllerToPresent animated:YES];
}
@davbeck
davbeck / gist:3661211
Created September 6, 2012 23:19
NSTimer with block
_actionDelayTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:[NSBlockOperation blockOperationWithBlock:^{
NSLog(@"Well this is useless.");
}] selector:@selector(start) userInfo:nil repeats:YES];