Skip to content

Instantly share code, notes, and snippets.

@icyleaf
icyleaf / post-receive.sh
Created September 6, 2010 07:55
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@cjus
cjus / jsonval.sh
Created June 26, 2011 17:42
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`
@skyisle
skyisle / icloud-ssh
Created February 18, 2012 01:44
Shell script to connect icloud host through ssh
#!/bin/bash
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` hostname"
exit $E_BADARGS
fi
HOSTNAME=$1
DOMAIN=$(echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p')
@jbub
jbub / clean-macports.sh
Created July 8, 2013 21:23
Clean macports temporary build files and remove inactive ports.
# remove all temporary build files
sudo port clean --all installed
# remove all inactive ports
sudo port -f uninstall inactive
@davisford
davisford / setup-avahi.sh
Created July 12, 2013 14:14
Setup avahi-daemon on Ubuntu for so you can reach hostname `ubuntu.local` from host OS
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan
@hwdsl2
hwdsl2 / .MOVED.md
Last active April 27, 2024 16:05
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@benkulbertis
benkulbertis / cloudflare-update-record.sh
Last active April 28, 2024 16:35
Cloudflare API v4 Dynamic DNS Update in Bash
#!/bin/bash
# CHANGE THESE
auth_email="user@example.com"
auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings
zone_name="example.com"
record_name="www.example.com"
# MAYBE CHANGE THESE
ip=$(curl -s http://ipv4.icanhazip.com)
@bruienne
bruienne / xhyverun.sh
Last active October 4, 2018 09:40
xhyve boot2docker sample config
#!/bin/sh
KERNEL="/path/to/vmlinuz64"
INITRD="/path/to/initrd.img"
#CMDLINE="earlyprintk=serial console=ttyS0 acpi=off"
CMDLINE="loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10:LABEL=boot2docker-data base"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net,en0"
@mikaelhg
mikaelhg / Demo.java
Last active May 4, 2022 06:49
Spring Boot @scheduled + Spring Security @PreAuthorize = RunAs
@Service
class FooService {
@Inject FooDao dao;
@Scheduled(fixedRate = 600000L, initialDelay = 60000L)
public void periodicalTask() throws IOException {
RunAs.runAsAdmin(() -> {
dao.save(new Foo(...));
});