Skip to content

Instantly share code, notes, and snippets.

View itmammoth's full-sized avatar
🏯
Working from castle

itmammoth itmammoth

🏯
Working from castle
View GitHub Profile
@pastleo
pastleo / nm_l2tp_ipsec_vpn.md
Last active May 4, 2024 01:12
setup L2TP IPSEC VPN in archlinux using NetworkManager
@zchee
zchee / actionlist.vim
Last active April 19, 2024 13:22
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@oshliaer
oshliaer / .en.md
Last active September 30, 2020 02:33
Create a Gmail draft with attachments via Google Apps Script #gas #gmail
@itmammoth
itmammoth / start_emulator.sh
Last active September 21, 2020 07:33
Start an android emulator with changing DNS server to Google public DNS
#!/bin/bash
EMULATOR=~/Library/Android/sdk/tools/emulator
if [ $# -ne 1 ]; then
echo "ERROR: Please specify the target AVD from the list below" 1>&2
$EMULATOR -list-avds 1>&2
exit 1
fi
$EMULATOR -avd $1 -dns-server "8.8.8.8,8.8.4.4"
@itmammoth
itmammoth / jquery.autoAdjust.js
Last active May 26, 2019 08:23
jQuery plugin that provides auto-extension (currently `width` is only supported) to elements
/**
* ex)
* <input type="text" class="jq-auto-adjust" data-base-width="60" data-base-window-width="1280">
* $('.jq-auto-adjust').autoAdjust();
*/
(function($) {
'use strict';
var methods = {
init: function(options) {
@itmammoth
itmammoth / safe.kt
Created May 25, 2019 06:44
[Kotlin] Unwrap null objects or return immediately
fun <T1, T2> safe(t1: T1?, t2: T2?): Pair<T1, T2>? {
return if (t1 == null || t2 == null) null else Pair(t1, t2)
}
fun <T1, T2, T3> safe(t1: T1?, t2: T2?, t3: T3): Triple<T1, T2, T3>? {
return if (t1 == null || t2 == null || t3 == null) null else Triple(t1, t2, t3)
}
// Usage (case in fragments)
val (context, activity) = safe(context, activity) ?: return
@itmammoth
itmammoth / file0.txt
Last active July 27, 2018 08:08
kotlinでif文の条件に代入式を使いたい ref: https://qiita.com/itmammoth/items/e21dba17373e0aa7353e
if (val date = arguments?.getSerializable(ARG_DATE) as LocalDate) {
...
@itmammoth
itmammoth / backboneSortable.js
Last active May 17, 2018 03:52
A jQuery plugin over jQueryUI sortable that arranges Backbone.Collection and item views as the html list are
/**
* $.backboneSortable
*/
(function(){
var methods = {
init: function(options) {
var settings = $.extend({
// defaults
}, options);
/**
* Usage:
* var models = [{ attributes: { name: 'Scott' } }, { attributes: { name: 'Tiger' } }];
* deepPluck(models, 'attributes', 'name'); //=> ['Scott', 'Tiger']
*/
var deepPluck = function(array) {
var copiedArray = [].concat(array);
for (var i = 1; i < arguments.length; i++) {
copiedArray = _.pluck(copiedArray, arguments[i]);
}