Skip to content

Instantly share code, notes, and snippets.

View JayKandari's full-sized avatar
:octocat:

Jaideep Singh Kandari JayKandari

:octocat:
View GitHub Profile
@mhemesath
mhemesath / transformToMatrix.js
Created October 9, 2012 03:01
Converts a SVG transform string into a Raphael Matrix object.
function toMatrix(transform) {
var transforms = transform.split(' '),
matrix = Raphael.matrix();
for (var i=0; i<transforms.length; i++) {
var match = /^(\w+)\((.+)\)$/.exec(transforms[i]),
tranform = match[1],
values = toFloatArray(match[2]);
if ('translate' === transform) matrix.translate.apply(matrix, values);
@clops
clops / JavaScriptGames.txt
Last active January 25, 2021 20:26
Crazy! Collection of JavaScript games made in under 35 lines of code
36 Line Tetris --> http://jsfiddle.net/ova777/kFxja/
30 Line Sokoban --> http://jsfiddle.net/zabbius/nU74f/
34 Line Minesweeper --> http://jsfiddle.net/c884a/
30 Line Arcanoid --> http://jsfiddle.net/martin_/Fq8F4/
30 Line Snake --> http://jsfiddle.net/Uk2PP/9/
30 Line Excel --> http://jsfiddle.net/zag2art/b3pbw/4/
30 Line Race --> http://jsfiddle.net/Minimajack/C545E/embedded/result/
37 Line PONG --> http://jsfiddle.net/WNrfp/6/
@brainwipe
brainwipe / snap.svg.snapping.html
Created November 27, 2013 10:38
Using Snap.svg to create a draggable box that snaps to grid.
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js"></script>
<script>
var s = Snap("#svg");
var gridSize = 50;
var orig = {
x: 0,
y: 0
@brainwipe
brainwipe / snap.svg.text.in.a.box.html
Last active May 27, 2022 00:03
Using Snap.svg to create a box with text in it. The bounding "container" box expands to fit the width of the text.
<html>
<head>
<script src="//cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js"></script>
<script>
var s = Snap("#svg");
var block = s.rect(50, 50, 100, 100, 20, 20);
block.attr({
fill: "rgb(236, 240, 241)",
stroke: "#1f2c39",
@crittermike
crittermike / gist:7b654d3d686a4e434eda
Created March 26, 2015 00:56
Run a single specific Drupal update hook using Drush
drush php-eval "module_load_install('MYMODULE'); MYMODULE_update_NUMBER();"
@MahinAbbasianpoor
MahinAbbasianpoor / repeat_watermark_imagick.php
Last active May 25, 2020 22:04
repeat watermark image with imagick in php
// load images
$image = new Imagick("main_image.jpg");
$watermark = new Imagick("stamp.png");
// main image dimension
$geo=$image->getImageGeometry();
$x=$geo['width'];
$y=$geo['height'];
// stamp image dimension
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@Restuta
Restuta / framework-sizes.md
Last active April 19, 2025 05:14
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@AlexSkrypnyk
AlexSkrypnyk / mymodule.css
Last active April 17, 2024 08:37
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@aramboyajyan
aramboyajyan / snippet.php
Created February 7, 2016 09:54
Drupal 7 Commerce empty user shopping cart programmatically
global $user;
$order = commerce_cart_order_load($user->uid);
commerce_cart_order_empty($order);