Skip to content

Instantly share code, notes, and snippets.

View tlimpanont's full-sized avatar
🏠
Working from home

Theuy Limpanont tlimpanont

🏠
Working from home
View GitHub Profile
@tlimpanont
tlimpanont / mozilla-cookies.js
Created March 3, 2014 10:49
A complete cookies reader/writer framework with full unicode support.
/*\
|*|
|*| :: cookies.js ::
|*|
|*| A complete cookies reader/writer framework with full unicode support.
|*|
|*| https://developer.mozilla.org/en-US/docs/DOM/document.cookie
|*|
|*| This framework is released under the GNU Public License, version 3 or later.
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
@tlimpanont
tlimpanont / delete_instersect_map.js
Last active August 29, 2015 13:57
Vocabulary translation: delete keys and mapping intersected keys
if (!Array.prototype.intersect) {
Array.prototype.intersect = function (arr1) {
var r = [],
o = {}, l = this.length,
i, v;
for (i = 0; i < l; i++) {
o[this[i]] = true;
}
l = arr1.length;
@tlimpanont
tlimpanont / walk-dom-delete-classes.js
Last active August 29, 2015 14:00
find all nodes in DOM with RegExp and delete classNames
var walk_the_DOM = function walk(node, func) {
func(node);
node = node.firstChild;
while (node) {
walk(node, func);
node = node.nextSibling;
}
};
function removeRegExClassesFromDOM(className) {
@tlimpanont
tlimpanont / dabblet.css
Created June 23, 2014 10:32
CSS3 Fade in/out transition
#cf6_image {
margin:0 auto;
width:450px;
height:281px;
transition: background-image 1s ease-in-out;
background-image:url("http://css3.bradshawenterprises.com/images/Cirques.jpg");
}
#cf6_image:hover {
background-image:url("http://css3.bradshawenterprises.com/images/Clown%20Fish.jpg");
@tlimpanont
tlimpanont / items_template.html
Last active August 29, 2015 14:03
How to devide items into sections with array.slice method
<!-- I want to devide this itemList in to 3 sections. Each section should contain max 2 items.
#Section 1
<li>1</li>
<li>2</li>
#Section 2
<li>3</li>
<li>4</li>
@tlimpanont
tlimpanont / lodashSortSpec.js
Created July 18, 2014 10:00
Testing _. lodash sortBy function for grid list view
describe('_.sortBy of lodash',function(){
var descData = [
{title: "B", number: 2, date: new Date("October 2, 2014") },
{title: "A", number: 1, date: new Date("October 1, 2014") },
];
var ascData = [
{title: "A", number: 1, date: new Date("October 1, 2014") },
{title: "B", number: 2, date: new Date("October 2, 2014") },
];
@tlimpanont
tlimpanont / filtering_sorting_field_selection_paging.txt
Last active March 10, 2021 09:43
RESTful best practices Query String Params
<?php
/*
Based on http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/
7. Provide filtering, sorting, field selection and paging for collections
*/
/******
@tlimpanont
tlimpanont / Pagination.js
Last active April 22, 2020 15:05
Pagination Class for javascript
var Pagination = function(list, itemsPerPage) {
this.list = list;
this.itemsPerPage = itemsPerPage;
this.currentPageNumber = null;
this.currentPageIndex = null;
this.currentPageItems = [];
this.totalItems = this.list.length;
this.totalPages = Math.ceil(this.totalItems / this.itemsPerPage );
this.toFirstPage();
@tlimpanont
tlimpanont / souncloud-embed-player.md
Last active August 29, 2015 14:04
Soundcloud embed page, search and combining clientId and trackId to resource URL

TO GET TO MP3 file with JSON API of soundcloud

https://api.soundcloud.com/i1/tracks/160637550/streams?client_id=0f8fdbbaa21a9bd18210986a7dc2d72c&format=json

What we need to know is the trackID and the ClientID

TrackID can be found in the data-src="" attr

<iframe src="about:blank" frameborder="no" scrolling="no" width="100%" height="166" data-src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/160637550&amp;color=ff0000&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false" class="npo_cc_social npo_cc_processed" cookiewall-checked="true"></iframe>
@tlimpanont
tlimpanont / angular-ng-validate.scss
Last active August 29, 2015 14:05
ng validate success and error form style
input.ng-dirty.ng-invalid, input.ng-pristine.ng-invalid
textarea.ng-dirty.ng-invalid, textarea.ng-pristine.ng-invalid
select.ng-dirty.ng-invalid, select.ng-pristine.ng-invalid {
border: 1px solid #e9322d;
&:focus {
border: 1px solid #e9322d;
-webkit-box-shadow: 0 0 6px #f8b9b7;
-moz-box-shadow: 0 0 6px #f8b9b7;
box-shadow: 0 0 6px #f8b9b7;
}