This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.isBefore = function(e2) { | |
// var all = $(context || document).find("*"); | |
// return all.index(this[0]) < all.index($(sel)); | |
let e1 = $(this).get(0); | |
e2 = $(e2).get(0); | |
let p1 = $(e1).parents(); // returns a jQuery object | |
let p2 = $(e2).parents(); // ordrered from the immediate parent up | |
for (var i1 = 0; i1 < p1.length; i1++) { | |
let i2 = p2.index(p1[i1]); | |
if (i2 >= 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks https://css-tricks.com/converting-color-spaces-in-javascript/ | |
export const rRGB = /^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/; | |
export const rHSL = /^hsl\((\d{1,3}), (\d{1,3})%, (\d{1,3})%\)$/; | |
export const rHTML = /^#[0-9a-f]{6}$/i; | |
export function toRgb(input) { | |
if (input && typeof input === 'object') { | |
if (input.hsl) { | |
return hslToRgb(input); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Call when dragging starts, returns handler. | |
// Call handler.stop() when dragging stops. | |
export function startAutoscroll() { | |
const GUTTER_SIZE = 70; // distance from edge of viewport where scrolling starts | |
const SCALE_RANGE = 8; // higher value gives potential for faster scrolling | |
const $window = $(window); | |
let requestId = null; | |
let clientY = null; // cursor position within viewport |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YouTube embed regex: | |
/<iframe\s+[^>]*?src="(?:(?:https?:)?\/\/)?(?:(?:www|m)\.)?(?:youtube\.com|youtu.be)(?:\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)[^">]*?"[^>]*>[^<]*<\/iframe>/ | |
Vimeo embed regex: | |
/<iframe\s+[^>]*?src="(?:(?:https?:)?\/\/)?(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/|)(\d+)\/?(?:[?]?[^">]*)"[^>]*>[^<]*<\/iframe>/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.post('/ajax/test', { | |
field, | |
}).then(response => { | |
// Success | |
}).fail((jqXHR) => { | |
if (jqXHR.status === 409) { | |
alert('Conflict'); | |
} else { | |
alert('Error code: ' + jqXHR.status); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a data-toggle=".demo-layout .demo-target" href="#">[-]</a> | |
<div class="demo-layout"> | |
<div class="demo-target"> | |
<p>Content hidden or displayed</p> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure all AVDs are closed, and your Android device is connected. | |
# To make a backup of the ca.mattcudmore.day2day app: | |
~/Library/Android/sdk/platform-tools/adb backup -f backup.ab ca.mattcudmore.day2day | |
# Convert the backup file to TAR: | |
dd if=backup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > backup.tar | |
# Extract the TAR to access files. | |
tar -xvf backup.tar | |
# Now disconnect Android device and launch AVD where files will be copied to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.macu.sppreader; | |
import android.app.ProgressDialog; | |
import android.bluetooth.BluetoothAdapter; | |
import android.bluetooth.BluetoothDevice; | |
import android.bluetooth.BluetoothSocket; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
import android.view.View; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<style> | |
.drop-area { | |
display: inline-block; | |
padding: 1em; | |
border: thin dotted grey; | |
border-radius: 1em; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<textarea rows=4 cols=40></textarea> | |
<br/> | |
<button onclick="saveTextarea()">Save text</button> | |
<br/> | |
<br/> | |
<button onclick="save256Bytes()">Save example typed array as binary file</button> |
NewerOlder