Skip to content

Instantly share code, notes, and snippets.

@igez
igez / slugify.js
Created December 15, 2017 03:15 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@igez
igez / index.html
Last active July 21, 2017 11:04
2D coordinate in transformed svg
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
.node.active {
stroke: #333;
stroke-dasharray: 5, 2;
stroke-width: 2;
}
</style>
<svg width='960' height='600'>
@igez
igez / index.html
Last active April 27, 2019 12:57
Binding update example
<!DOCTYPE html>
<meta charset='utf-8'>
<svg width='960' height='600'></svg>
<script src='https://d3js.org/d3.v4.min.js'></script>
<script>
var svg = d3.select('svg'),
width = +svg.attr('width'),
height = +svg.attr('height');
var color = d3.scaleOrdinal(d3.schemeCategory20);
@igez
igez / index.html
Last active May 30, 2017 07:56
D3 range slider example
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
.control {
cursor: ew-resize;
}
</style>
<svg width='960' height='600'></svg>
<script src='https://d3js.org/d3.v4.min.js'></script>
<script>
@igez
igez / index.html
Created May 7, 2017 16:38
Move circle to mouse position at constant speed
<!DOCTYPE html>
<meta charset='utf-8'>
<svg width='960' height='600'>
<defs>
<pattern>
<pattern id="pat" width="22" height="22" patternUnits="userSpaceOnUse">
<path d="M 0 0 L 22 0 22 22 0 22 z" stroke="#eee" stroke-width="1" fill="none"></path>
</pattern>
</pattern>
@igez
igez / index.html
Last active May 7, 2017 06:33
Circles with drag function and animation
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
.node {
stroke: #000;
stroke-width: 1.5px;
}
.node.dragged {
stroke: #000;
@igez
igez / slackpost
Created February 7, 2017 10:20 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@igez
igez / sample.json
Last active December 19, 2016 04:37
[
{
"name":"PT Angin Ribut",
"states":[
{
"title":"Introduction",
"cards":[
{
"name":"Card #1"
}
@igez
igez / v8js.sh
Created December 5, 2016 10:16
Install V8js php extension on ubuntu
#!/bin/bash
apt-get update
apt-get install -y build-essential chrpath git
cd /tmp
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
-- https://www.percona.com/blog/2008/02/04/finding-out-largest-tables-on-mysql-server/
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;