Skip to content

Instantly share code, notes, and snippets.

@qrtt1
qrtt1 / gradle.tips.condition.md
Last active August 29, 2015 13:57
Gradle Notes

在 gradle 內,執行特定 task 時,需要不同的設定時,可以透 taskGraph 來判斷。下面這例子,很典型地是在 publish 新的 library 時,不含設定檔:

gradle.taskGraph.whenReady { graph ->
    if (graph.hasTask(uploadArchives)) {
        jar {
            exclude '**/*.properties'
        }
 }

使用 gcloud 由 snapshot 建出機器並加入 loading balancer

--

THE_SNAPSHOT_NAME snapshot 建出一顆 disk MY_INSTANCE

gcloud compute disks create MY_INSTANCE --source-snapshot THE_SNAPSHOT_NAME --zone asia-east1-c
import org.apache.commons.lang.StringUtils;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;
import scala.Tuple2;
from BeautifulSoup import BeautifulSoup as Soup
from mechanize import Browser
from soupselect import select
from datetime import datetime
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
@philipz
philipz / gist:67892bdc8a385ecb3b8c
Last active November 14, 2017 22:57
Rsync & Docker save

Rsync & Docker save

docker save $1 > $1.tar && rsync -ravP -e ssh $1.tar philipz@192.168.2.51:/home/philipz/tmp && rm $1.tar ##Add Gzip docker save busybox | gzip -c - > busybox.tar.gz

gzip -d busybox.tar.gz && docker load < busybox.tar

docker save busybox | gzip | pv | ssh -i ~/.ssh/id_rsa USER@HOSTNAME sudo docker load

@vidoss
vidoss / gist:2178987
Created March 24, 2012 06:20
Using underscore.js while scripting mongodb shell.
MongoDB provides a Javascript shell. But Javascript is no fun without underscore.js
Turned out its straight forward to use underscore.js while scripting mongodb.
Here are the steps.
1) Use underscore to write your db script file (say my_commands.js)
E.g: _.each(db.dbname.find().toArray(), function(itm) { ... })
@justenwalker
justenwalker / unsafeAssassinateEndpoint.md
Created January 9, 2014 17:33
Cassandra unsafe assassinate - removing a dead node from the cluster

Unsafe Node Assassinate

On Cassandra 1.1.x, nodetool removetoken on a dead node hangs. The only way to reliably remove the node from the cluster is to use an undocumented JMX command to force the remove of the node from gossip.

Upgrading to 1.2.x and above should obviate these steps in favor of nodetool removenode - See 1.2 Docs

It's probably also a good idea to run a nodetool repair after this operation - See wiki

Prerequisites

@eshizhan
eshizhan / conv2vmx-ovf.py
Last active April 25, 2021 22:05
a script that can help import VMs into VMware ESXi from VirtualBox. tested vbox 4.2.18 and ESXi 5.1.
#!/usr/bin/env python
#
# usage:
# conv2vmx-ovf.py some-vm.ovf
#
# ref: http://www.cnblogs.com/eshizhan/p/3332020.html
#
import sys
fn = sys.argv[1]
@proudlygeek
proudlygeek / client_cors.js
Created July 17, 2012 20:48
JSONP Vs. CORS
// http://jsfiddle.net/suBPQ/
$.ajax({
url: "http://api_test_server.proudlygeek.c9.io/",
success: function(data) {
console.log(data);
}
});​
@calvinlfer
calvinlfer / script.sh
Last active March 2, 2022 06:52
Pushing Jenkins ThinBackup backups to S3
#!/bin/bash -l
# find latest backup
thinbackup_path="$JENKINS_HOME/thinBackup"
latest_backup_folder=$(ls -t $thinbackup_path | head -n1)
full_path="$thinbackup_path/$latest_backup_folder"
echo "Latest backup is located at ${full_path}"
# pack it up
backup_name="$latest_backup_folder.tar.gz"