Skip to content

Instantly share code, notes, and snippets.

@un33k
un33k / sed cheatsheet
Created August 22, 2011 13:28
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@MoshDev
MoshDev / installRun.gradle
Last active June 9, 2023 15:41
Install and Run Android App Using Gradle Task
//Place this script inside your application module build.gradle
//It will create a new task(s) based on your application variants within (run) group
//sample: ./gradlew installRunDebug
//sample: ./gradlew installRunStagDebug
project.afterEvaluate {
android.applicationVariants.all { variant ->
task "installRun${variant.name.capitalize()}"(type: Exec, dependsOn: "install${variant.name.capitalize()}", group: "run") {
commandLine = ["adb", "shell", "monkey", "-p", variant.applicationId + " 1"]
doLast {
/*
* Part of Ensemble CSS
* related to AdvCandleStickChart
*
* extracted by Nicolas
* July 20th, 2016
*
* Initial CSS:
* http://grepcode.com/file/repo1.maven.org/maven2/org.jbundle.javafx.example/org.jbundle.javafx.example.ensemble/0.9.0/ensemble/ensemble2.css?av=f
*
@mestizo
mestizo / gist:9167834
Last active February 27, 2023 22:39
Completely disable IPv6 on OSX
#To Get List of Hardware
sudo networksetup -listallhardwareports
#To Disable IPv6 on Wifi Adapter
sudo networksetup -setv6off wi-fi
#To Disable IPv6 on Built-in Ethernet Adapter
sudo networksetup -setv6off Ethernet
@visenger
visenger / install_scala_sbt.sh
Last active January 31, 2023 19:10
Scala and sbt installation on ubuntu 12.04
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb
sudo dpkg -i scala-2.11.4.deb
sudo apt-get update
@gre
gre / deploy.sh
Last active October 8, 2021 00:33
Super-small scripts for easy PlayFramework deployment
#!/bin/bash
REMOTE=play@SERVER_IP
REMOTE_APP=/home/play/PROJECT_NAME/
sbt stage || exit 1;
rsync -va target/ $REMOTE:$REMOTE_APP/target;
ssh $REMOTE "cd $REMOTE_APP; ./stop.sh";
ssh $REMOTE "cd $REMOTE_APP; ./start.sh";
@spoike
spoike / reflux.js
Created June 29, 2014 22:23
A simpler implementation of React.JS's Flux
var EventEmitter = require('events').EventEmitter,
_ = require('lodash');
/**
* Creates an action functor object
*/
exports.createAction = function() {
var action = new EventEmitter(),
eventLabel = "action",
@teabyii
teabyii / Riot-compiler.md
Last active November 15, 2018 09:11
Riot-compiler 代码的简单解读

Riot 源码阅读笔记 -- compiler

关于 Riot 的 compiler,具体请见:[Riot compiler]

之前在 [Riot 源码阅读笔记] 中提到另挖坑来聊聊 Riot 提供的 template + logic compiler 是怎么干活的,于是有了这一篇文章... (其实大部分都是正则,正则)

Riot 提供了两种方式,分别是 pre-compile 和直接在页面使用 script[type="riot/tag"],都是用的同一个 compiler 来处理代码的解析,在真实环境时推荐使用 pre-compile 的方式。

在页面使用 script[type="riot/tag", src="path"] 和 React 在页面使用 script[type="text/jsx", src="path"] 一样,都是用了 ajax 来请求文件内容,跨域就拜拜了,请知悉。

@SamuelMarks
SamuelMarks / egghead_YouTube_downloader.py
Last active November 3, 2018 09:32
Simple algorithm to download all the egghead.io videos in highest-quality from YouTube.
"""
Simple algorithm to download all the egghead.io videos in highest-quality from YouTube.
Run from the directory you want the videos to appear. Renames them so that they have the video number + omit the repetitive "Egghead.io - AngularJS -" text.
Installing dependency:
$ pip install git+https://github.com/NFicano/pytube#egg=pytube
"""
from pytube import YouTube #, exceptions as YTD_exceptions
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10:
brew install https://raw.github.com/gist/4340744/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0