This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// read the template file | |
InputStream stream = getClass().getClassLoader().getResourceAsStream("myFile.haml"); | |
String template = IOUtils.toString(stream); | |
// initialize the options | |
Map<Object, Object> options = new HashMap<Object, Object>(); | |
options.put("format", "html5"); | |
// initialize the engine | |
HamlEngine engine = new HamlEngine(template, options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ImageHelper extends Helper { | |
var $helpers = array('Html'); | |
var $cacheDir = 'cache'; // relative to IMAGES_URL path | |
function resize($path, $dst_w, $dst_h, $htmlAttributes = array(), $return = false) { | |
$types = array(1 => "gif", "jpeg", "png", "swf", "psd", "wbmp"); // used to determine image type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Class util = Class.forName("com.apple.eawt.FullScreenUtilities"); | |
Class params[] = new Class[2]; | |
params[0] = Window.class; | |
params[1] = Boolean.TYPE; | |
Method method = util.getMethod("setWindowCanFullScreen", params); | |
method.invoke(util, this, true); | |
} catch (ClassNotFoundException e) { | |
// log exception | |
} catch (NoSuchMethodException e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Class util = Class.forName("com.apple.eawt.Application"); | |
Method getApplication = util.getMethod("getApplication", new Class[0]); | |
Object application = getApplication.invoke(util); | |
Class params[] = new Class[1]; | |
params[0] = Image.class; | |
Method setDockIconImage = util.getMethod("setDockIconImage", params); | |
URL url = App.class.getClassLoader().getResource("icon.png"); | |
Image image = Toolkit.getDefaultToolkit().getImage(url); | |
setDockIconImage.invoke(application, image); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isSame(URL a, URL b, int depth) throws IOException { | |
HttpURLConnection conn = (HttpURLConnection) b.openConnection(); | |
conn.setInstanceFollowRedirects(false); | |
conn.connect(); | |
int d = 0; | |
while (conn.getResponseCode() >= 300 && conn.getResponseCode() <= 399 && d < depth) { | |
b = new URL(conn.getHeaderField("Location")); | |
conn = (HttpURLConnection) b.openConnection(); | |
conn.setInstanceFollowRedirects(false); | |
conn.connect(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.placeholder(@color) { | |
&::-webkit-input-placeholder { | |
color: @color; | |
} | |
&:-moz-placeholder { | |
color: @color; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decodeUrlParameter(str) { | |
return decodeURIComponent((str+'').replace(/\+/g, '%20')); | |
} | |
function getUrlParameter(name) { | |
return decodeUrlParameter(decodeURI( | |
(RegExp(name + '=' + '(.*?)(&|$)').exec(location.search)||[,null])[1] | |
)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decodeUrlParameter(str) { | |
return decodeURIComponent((str+'').replace(/\+/g, '%20')); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -t nat -F | |
iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j | |
REDIRECT --to-ports 9000 | |
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT | |
--to-port 9000 |
OlderNewer