Skip to content

Instantly share code, notes, and snippets.

@hwdsl2
hwdsl2 / .MOVED.md
Last active May 2, 2024 01:39
IPsec VPN Server Auto Setup Script for CentOS and RHEL
@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)
@hwdsl2
hwdsl2 / .MOVED.md
Last active April 27, 2024 16:05
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
@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
@darkwave
darkwave / proxy.py
Created March 12, 2016 22:42
Python proxy server to redirect calls from localhost to different address (change forward_to variable)
#!/usr/bin/python
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don't Care) license
import socket
import select
import time
import sys
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0" />
</head>
<body>
<div id="editor" contenteditable="true"></div>
</body>
</html>
@Jamesits
Jamesits / caddy.sh
Last active January 27, 2024 14:47
Install Caddy Server on Ubuntu with Systemd.
# Should work on all Debian based distros with systemd; tested on Ubuntu 16.04+.
# This will by default install all plugins; you can customize this behavior on line 6. Selecting too many plugins can cause issues when downloading.
# Run as root (or sudo before every line) please. Note this is not designed to be run automatically; I recommend executing this line by line.
apt install curl
curl https://getcaddy.com | bash -s personal dns,docker,dyndns,hook.service,http.authz,http.awses,http.awslambda,http.cache,http.cgi,http.cors,http.datadog,http.expires,http.filemanager,http.filter,http.forwardproxy,http.geoip,http.git,http.gopkg,http.grpc,http.hugo,http.ipfilter,http.jekyll,http.jwt,http.locale,http.login,http.mailout,http.minify,http.nobots,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.reauth,http.restic,http.upload,http.webdav,net,tls.dns.auroradns,tls.dns.azure,tls.dns.cloudflare,tls.dns.cloudxns,tls.dns.digitalocean,tls.dns.dnsimple,tls.dns.dnsmadeeasy,tls.dns.dnspod,tls.dns.dyn,tls.
@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`
@nickcheng
nickcheng / appdocdir.zsh
Last active May 15, 2023 15:28
Open your app's Documents folder on iOS simulator.
function myappdocdir() {
devid=$(xcrun simctl list devices | grep Booted | sed -n 's/^.*\([A-F0-9]\{8\}-\([A-F0-9]\{4\}-\)\{3\}[A-F0-9]\{12\}\).*$/\1/p')
for folder in ~/Library/Developer/CoreSimulator/Devices/$devid/data/Containers/Data/Application/*; do
if [[ -a $folder/.com.apple.mobile_container_manager.metadata.plist ]]; then
if [[ 'com.apple.phone' = $(/usr/libexec/PlistBuddy -c 'Print :MCMMetadataIdentifier' $folder/.com.apple.mobile_container_manager.metadata.plist) ]]; then
echo $folder
break
fi
fi
done
@lukaspili
lukaspili / ScrollableViewController.swift
Last active March 17, 2023 12:35
Scroll view snap kit
import UIKit
import SnapKit
class ScrollableViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.whiteColor()
let scrollView = UIScrollView()