Skip to content

Instantly share code, notes, and snippets.

View onigetoc's full-sized avatar

Gino onigetoc

View GitHub Profile
@niyazpk
niyazpk / pQuery.js
Created October 25, 2014 14:03
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@anandthakker
anandthakker / index.js
Created March 7, 2015 02:24
Twitter search API test
// Usage: node index.js "twitter search string"
var request = require('request');
// Grab a bearer token using application-only auth
// (doc: https://dev.twitter.com/oauth/application-only)
@hideokamoto
hideokamoto / get_hot_tag.html
Last active December 1, 2016 08:34
Get Plugin-Data fromWordPress.org API
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="wp_org_api"></div>
<script>
//setUp Post Data
var actionType = 'hot_tags';
var number = 10;
var timeout = 15;
//Parse Post Data
var postData = {
@DingGGu
DingGGu / stream.js
Last active November 23, 2024 18:21
NodeJS Mp3 Streaming ExpressJS
var express = require('express');
var app = express();
var fs = require('fs');
app.listen(3000, function() {
console.log("[NodeJS] Application Listening on Port 3000");
});
app.get('/api/play/:key', function(req, res) {
var key = req.params.key;
@dgp
dgp / youtube api video category id list
Created June 11, 2015 05:57
youtube api video category id list
2 - Autos & Vehicles
1 - Film & Animation
10 - Music
15 - Pets & Animals
17 - Sports
18 - Short Movies
19 - Travel & Events
20 - Gaming
21 - Videoblogging
22 - People & Blogs
@mattbell87
mattbell87 / README.md
Last active July 15, 2022 08:19
jQuery plugin for Long-press

Longpress plugin for jQuery

This plugin detects a long press on any element for a specified amount of time.

Installation

  • Copy longpress.js to your website
  • Include it in your HTML after you include jQuery.

Usage

@scottopolis
scottopolis / wp-api-user-meta.php
Last active April 18, 2020 19:13
Add user meta to the WP-API
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@christopherlovell
christopherlovell / m3u-2-JSON.R
Created November 1, 2015 21:49
m3u to JSON converter
library(rjson)
trim <- function (x) gsub("^\\s+|\\s+$", "", x)
data_dir = 'Documents/playlists/'
play_list = list()
for(i in list.files(data_dir,"^.*\\.(m3u)$")){
year = substr(i,1,4) # record file specific information, in this case year from playlist group
@christophengelmayer
christophengelmayer / ajax.js
Created November 3, 2015 10:32
Vanilla JavaScript AJAX Function
var ajax = (function () {
var ajax = {};
ajax.get = function (url, callbackFunc) {
var req = prepareRequest('GET', url, callbackFunc);
req.send();
}
ajax.post = function (url, params, callbackFunc) {
var req = prepareRequest('POST', url, callbackFunc);