Skip to content

Instantly share code, notes, and snippets.

@richard512
richard512 / svg-css-text-animation.htm
Created May 10, 2015 08:42
SVG Text Stroke Animation Via CSS. Demo: http://jsbin.com/fekigigeli
<svg width="500" height="150">
<text x="100" y="80" fill="none" stroke="black" stroke-width="1" font-size="50">Loading...</text>
</svg>
<style>
text {
font-family: sans-serif;
stroke-dasharray: 100%;
stroke-dashoffset: 100%;
@richard512
richard512 / writing-animation-js.htm
Last active August 29, 2015 14:20
Text Writing Animation on Canvas via JS. Demo: http://jsbin.com/navawinifi
<canvas width=600></canvas>
<script>
var ctx = document.querySelector("canvas").getContext("2d"),
dashLen = 220, dashOffset = dashLen, speed = 5,
txt = "Loading...", x = 0, i = 0;
ctx.font = "50px Comic Sans MS, cursive, TSCu_Comic, sans-serif";
ctx.lineWidth = 5;
ctx.lineJoin = "round";
@richard512
richard512 / month-name-number-conversion.js
Last active November 21, 2022 03:19
JavaScript: Month name to Number and Month number to month name
var months = [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
];
function monthNumToName(monthnum) {
return months[monthnum - 1] || '';
}
function monthNameToNum(monthname) {
@richard512
richard512 / jquery-check-element-visibility.js
Created May 10, 2015 11:50
jQuery Check if Element is Visible
$(element).is(":visible");
@richard512
richard512 / word-frequency.js
Last active August 29, 2015 14:20
JavaScript Word Frequency
function wordFreq(sWords) {
// make sure input looks right
if (!sWords) return false;
if (typeof sWords != 'string') return false;
// converts to lowercase. trims leading and trailing spaces
// removes all commas, semicolins, and periods
// converts string to array of words, split by space
sWords = sWords.toLowerCase().trim();
sWords = sWords.replace(/[,;.]/g, '');
@richard512
richard512 / css-vignette.css
Last active September 7, 2015 13:11
Make a Vignette with CCS3
.vignette {
-webkit-box-shadow: inset 0px 0px 85px rgba(0,0,0,0.4);
-moz-box-shadow: inset 0px 0px 85px rgba(0,0,0,0.4);
box-shadow: inset 0px 0px 85px rgba(0,0,0,0.4);
line-height: 0; /* ensure no space between bottom */
display: inline-block; /* don't go wider than image */
}
.vignette img {
@richard512
richard512 / jquery-waitUntilExists.js
Created May 28, 2015 22:00
Run JS function when document element exists -- A jQuery plugin
(function ($) {
/**
* @function
* @property {object} jQuery plugin which runs handler function once specified element is inserted into the DOM
* @param {function} handler A function to execute at the time when the element is inserted
* @param {bool} shouldRunHandlerOnce Optional: if true, handler is unbound after its first invocation
* @example $(selector).waitUntilExists(function);
*/
@richard512
richard512 / reddit-comment-word-frequency.js
Last active August 29, 2015 14:23
reddit comment word frequency analysis in javascript
function wordFreq(sWords) {
// make sure input looks right
if (!sWords) return false;
if (typeof sWords != 'string') return false;
// converts to lowercase. trims leading and trailing spaces
// removes all commas, semicolins, and periods
// converts string to array of words, split by space
sWords = sWords.toLowerCase().trim();
sWords = sWords.replace(/[,;.]/g, '');
@richard512
richard512 / waldo.js
Created September 7, 2015 13:41
Waldo: Search global JavaScript variables for strings, functions, etc.
// author: https://javascriptweblog.wordpress.com/2011/07/11/waldo-search-the-javascript-runtime-in-under-1-kb/
(function(){
var traverse = function(util, searchTerm, options) {
var options = options || {};
var obj = options.obj || window;
var path = options.path || ((obj==window) ? "window" : "");
var props = Object.keys(obj);
props.forEach(function(prop) {
if ((tests[util] || util)(searchTerm, obj, prop)){
@richard512
richard512 / prepare_icons.sh
Last active November 12, 2023 23:02 — forked from Lerg/prepare_icons.sh
Make all app icons with imagemagick, iOS and Android
#!/bin/sh
base=$1
convert "$base" -resize '29x29' -unsharp 1x4 "Icon-Small.png"
convert "$base" -resize '40x40' -unsharp 1x4 "Icon-Small-40.png"
convert "$base" -resize '50x50' -unsharp 1x4 "Icon-Small-50.png"
convert "$base" -resize '57x57' -unsharp 1x4 "Icon.png"
convert "$base" -resize '58x58' -unsharp 1x4 "[email protected]"
convert "$base" -resize '60x60' -unsharp 1x4 "Icon-60.png"
convert "$base" -resize '72x72' -unsharp 1x4 "Icon-72.png"
convert "$base" -resize '76x76' -unsharp 1x4 "Icon-76.png"