Skip to content

Instantly share code, notes, and snippets.

View gnepud's full-sized avatar

Peng Du gnepud

  • Grenoble, France
View GitHub Profile
@gnepud
gnepud / nl.sh
Last active August 29, 2015 14:15 — forked from yyx990803/nl.sh
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"
@gnepud
gnepud / gist:1101781
Created July 23, 2011 19:25
Using chmod to recursively change directories / files
cf: http://www.linuxquestions.org/questions/linux-software-2/using-chmod-to-recursively-change-directories-files-293310/
find [YOURDIR] -type d -exec chmod 755 {} \;
find [YOURDIR] -type f -exec chmod 644 {} \;
@gnepud
gnepud / gist:1188541
Created September 2, 2011 12:58
Difference of asynchronous and synchronous programming
Asynchronous programming
JavaScript:
var a = 'foo';
//lots of code
setTimeout(function(){ //Beginning of code that should run AFTER the timeout
alert(a);
//lots more code
},5000);
alert('before foo');
@gnepud
gnepud / gist:1216580
Created September 14, 2011 13:44
Example of breakpoints using closures for JavaScript
// http://www.davidflanagan.com/javascript5/display.php?n=8-7&f=08/07.js
// This function implements a breakpoint. It repeatedly prompts the user
// for an expression, evaluates it with the supplied self-inspecting closure,
// and displays the result. It is the closure that provides access to the
// scope to be inspected, so each function must supply its own closure.
//
// Inspired by Steve Yen's breakpoint() function at
// http://trimpath.com/project/wiki/TrimBreakpoint
//
@gnepud
gnepud / gist:1374271
Created November 17, 2011 19:50
Form css via code school
@font-face {
font-family: 'DroidSansRegular';
src: url('fonts/DroidSans-webfont.eot');
src: local('☺'), url('fonts/DroidSans-webfont.woff') format('woff'), url('fonts/DroidSans-webfont.ttf') format('truetype'), url('fonts/DroidSans-webfont.svg#webfontw7zqO19G') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'DroidSansBold';
src: url('fonts/DroidSans-Bold-webfont.eot');
@gnepud
gnepud / gist:1374431
Created November 17, 2011 20:34
Bottom css example1
/*
<div>
<a href="#" class="button"><span>Do Not Press This Button</span></a>
</div>
*/
.button {
display: inline-block;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
@gnepud
gnepud / gist:1374453
Created November 17, 2011 20:40
Image css example
/*
<div>
<a href="#" class="abbey">
<img src="SaintMichaelAbbey.jpg" alt="Saint Michel Abbey, France">
Saint Michel Abbey, France
</a>
</div>
*/
body {
@gnepud
gnepud / tabs.css
Created December 1, 2011 17:58
Tabs css
#tabs ul {
margin: 10px;
padding-left: 0;
display: inline-block;
}
#tabs ul li {
list-style: none;
float: left;
}
@gnepud
gnepud / gist:1429965
Created December 4, 2011 11:34
My pryrc work with Rails
Pry.config.editor = "mvim"
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
@gnepud
gnepud / gist:1640335
Created January 19, 2012 14:35 — forked from jarod022/gist:1640319
Méthode choose_layout (annule le layout si Ajax)
# dans application_controller
private
# Charge le layout qui porte le même nom que le Namespace
# retourne aucun layout si la requête est en AJAX
def choose_layout
namespace = self.class.name.split("::").first.downcase
(request.xhr?) ? nil : namespace
end