Skip to content

Instantly share code, notes, and snippets.

@trivektor
trivektor / gist:3185314
Created July 27, 2012 00:00
FTP a file in Ruby
ftp = Net::FTP.new(server, username, password)
ftp.passive = true
ftp.chdir('some dir')
uploaded_file = params[:file][:file]
ftp.putbinaryfile(uploaded_file.tempfile)
ftp.rename(File.basename(uploaded_file.tempfile.to_path), uploaded_file.original_filename)
@trivektor
trivektor / gist:3308491
Created August 9, 2012 22:15
JIRA ticket html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JIRA ticket template</title>
<style type="text/css">
div, p, h1 {
margin:0; padding:0;
}
body {
@trivektor
trivektor / gist:3337103
Created August 13, 2012 05:03
Push and pop animation for UINavigationController
// Copied from http://stackoverflow.com/questions/2215672/how-to-change-the-push-and-pop-animations-in-a-navigation-based-app
For Push:
MainView *nextView=[[MainView alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
@trivektor
trivektor / gist:3718745
Created September 13, 2012 23:54
YP logo css3
gradient_background(start_color, stop_color)
background linear-gradient(top, start_color, stop_color); /* Standard (W3C) */
background -moz-linear-gradient(center top, start_color, stop_color); /* FF */
background -webkit-gradient(linear, left top, left bottom, from(start_color), to(stop_color)); /* Chrome, Safari */
background -o-linear-gradient(top, start_color, stop_color); /* Opera */
body
background url(/images/darkdenim3.png) repeat
font-family Arial
font-size 12px
@trivektor
trivektor / gist:4496809
Created January 9, 2013 20:49
Inner radial gradient
background-image: -webkit-gradient(radial, 50% 50%, 1, 50% 50%, 283, color-stop(0, rgba(112, 66, 20, 0.2)), color-stop(1, rgba(112, 66, 20, 0.4)));
background-image: -webkit-radial-gradient(rgba(112, 66, 20, 0.2), rgba(112, 66, 20, 0.4));
background-image: -moz-radial-gradient(rgba(112, 66, 20, 0.2), rgba(112, 66, 20, 0.4));
background-image: radial-gradient(rgba(112, 66, 20, 0.2), rgba(112, 66, 20, 0.4));
-webkit-box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
-moz-box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
@trivektor
trivektor / gist:4525664
Created January 13, 2013 18:51
Removing shine effect from the buttons in a UINavigationBar
// http://pastebin.com/raw.php?i=Xdf49BgK
@interface UIBarButtonItem (UIBarButtonItem_customBackground)
+ (id) customBarButtonWithTitle:(NSString *)title target:(id)target selector:(SEL)selector;
+ (id) customBackButtonWithTitle:(NSString *)title target:(id)target selector:(SEL)selector;
@end
@implementation UIBarButtonItem (UIBarButtonItem_customBackground)
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@trivektor
trivektor / gist:5638160
Created May 23, 2013 18:10
Useful Unix commands
stat -c %a /etc/passwd
function myFunction (a, blabla, c, somethingElse, e, f) {
var obj = [];
//'(a, b, c, d, e, f)'
var tmp = arguments.callee.toString().match(/\(.*?\)/g)[0];
//["a", "b", "c", "d", "e", "f"]
var argumentNames = tmp.replace(/[()\s]/g,'').split(',');
[].splice.call(arguments,0).forEach(function(arg,i) {
obj.push({
// question is how to get variable name here?