Skip to content

Instantly share code, notes, and snippets.

@lordfriend
lordfriend / redis-q.js
Last active August 29, 2015 14:00
Wrap redis client using kriskowal/q promise
/**
* Wrap redis client using kriskowal/q promise
*/
var redis = require('redis');
var redisClient = redis.createClient();
var Multi = redis.Multi;
var Q = require('q');
var _ = require('underscore');
var object = function(o) {
@lordfriend
lordfriend / monokai-webstorm.css
Last active August 29, 2015 14:01
monokai-webstorm color scheme for Brackets.io
.cm-s-monokai-webstorm.CodeMirror {
background-color: #272822;
color: #F8F8F2;
-webkit-font-smoothing: subpixel-antialiased;
}
.cm-s-monokai-webstorm.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid #f8f8f0;
z-index: 3;
}
## To create a custom config for a mod create a file with the same name
## as the jar file and append ".conf", for craftbukkit this would be
## "craftbukkit.jar.conf".
## The following config is an example that lists all possible options,
## without actually changing anything (it remaps the commands on
## themselves)
##
## General configuration. If this contains a setting called "file" the
## [commands], [start] and [parse_*] sections will be loaded from this
## other file
@lordfriend
lordfriend / filter target by class
Created October 1, 2014 12:51
Use with event delegate when jquery is not available.
/**
* filter the event target for the nya-bs-option element.
* Use this method with event delegate. (attach a event handler on an parent element and listen the special children elements)
* @param target event.target node
* @param parent {object} the parent, where the event handler attached.
* @return the filtered target or null if no element satisfied the selector.
*/
var filterTarget = function(target, parent) {
var elem = target,
className;
@lordfriend
lordfriend / postCompile.js
Created November 19, 2014 07:31
grunt-markdown work with angular custom html
{
preCompile: function(src, context) {
var match = src.match(/<example>[\s\S]+?<\/example>/mg);
if(match && match.length > 0) {
match.forEach(function(example) {
var subMatch = example.match(/<file\s*name=".+?">[\s\S]+?<\/file>/mg);
var group, newExample = example,
htmlContent,
appName = 'example' + exampleCount + 'App',
htmlFileName,
@lordfriend
lordfriend / index.html
Created April 28, 2015 10:12
selectable table row directive which support none-selectable td element
<table>
<tbody>
<tr selectab-tr="pickRow()">
<td>some data</td>
<td>some data</td>
<td class="none-selectable">
<a href="someurl">Click this link will not execute pickRow() function</a>
</td>
</tr>
</tbody>
@lordfriend
lordfriend / 360px高度
Last active December 19, 2015 00:20
G+左侧边栏图片...
.M8jNpf {
overflow: visible !important;
}
.M8jNpf::before {
position: absolute;
content: url('https://lh6.googleusercontent.com/-KK4uX4DzKDs/UcsJhmwGBtI/AAAAAAAASA8/gpFUyCTqV9Q/w219-h360-no/tsukiko_small.gif');
width: 219px;
height: 360px;
top: 0px;
@lordfriend
lordfriend / java env var
Created July 29, 2013 07:56
use to create environment variables for jdk
export JAVA_HOME=/usr/jdk1.6_43
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH
@lordfriend
lordfriend / minecraft server control
Created July 29, 2013 07:57
control a server via screen on linux
#!/bin/sh
# Controls the minecraft server
#####################
#START CONFIGURATION#
#####################
# Replace the location path with the folder containing your CraftBukkit.jar or minecraft_server.jar file
LOCATION="/srv/craftbukkit"