Skip to content

Instantly share code, notes, and snippets.

View GitHub30's full-sized avatar
🌴
On vacation

GitHub30

🌴
On vacation
  • Osaka, Japan
View GitHub Profile
@brianpeiris
brianpeiris / gist:211909
Created October 16, 2009 17:41 — forked from danwrong/gist:175591
A serializeHash plugin for jQuery that allows you to submit a form using jQuery's ajax functions.
/***
The serializeHash method can be used to submit forms with an ajax request.
The result of serializeHash can be used as the 'data' option for jQuery's
built-in ajax methods and functions.
***/
(function($){
$.fn.serializeHash = function() {
var hash = {};
/***
Use serializeArray() to get an array of JSON objects for
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@shinout
shinout / to_kana_zenkaku.js
Last active December 25, 2020 02:15
半角カナを全角カナに変換するJavaScript
/**
* 半角カナを全角カナに変換する
* 半角スペースは変換しない
* 対応がとれない濁点、半濁点は変換しない
*/
function toKanaZenkaku(str) {
// lengthの等しい2つの文字列でkey-valueをつくる
const makeMap = (str1, str2) =>
str1
.split("")
@ryjkov
ryjkov / ping.php
Created December 26, 2011 12:17
PHP - Ping
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
$ping = 'ping -n 5 ';
} else {
$ping = 'ping -c 5 ';
}
$ping .= 'yandex.ru';
$ph = popen($ping, 'r') or die('popen() failed');
$output = '';
while ($buf = fgets($ph, 1024)) {
@femto113
femto113 / transpose.js
Last active September 6, 2023 00:28
one line transpose for 2-dimensional Javascript arrays
function transpose(a)
{
return a[0].map(function (_, c) { return a.map(function (r) { return r[c]; }); });
// or in more modern dialect
// return a[0].map((_, c) => a.map(r => r[c]));
}
@psebborn
psebborn / countCSSRules.js
Last active April 25, 2023 11:43
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@BrockA
BrockA / waitForKeyElements.js
Created May 7, 2012 04:21
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@jeromeetienne
jeromeetienne / dieassert.js
Created May 10, 2012 08:32
a console.assert which actually stop the execution
/**
* A console.assert which actually stop the exectution.
* default console.assert() is a plain display, such as console.log() or console.error();
* It doesnt stop the execution like assert() is meant to do. This is a little code to
* "workaround this limitation" :) thanks @jensarp
*
* Usage:
* console.assert(foo === bar); // Will throw if not equal
* console.assert(foo === bar, 'Dude, foo does not equal bar'); // Will throw with custom error message
*
@daaain
daaain / gist:3932602
Created October 22, 2012 17:06
Google App Script - Spreadsheet JSON export
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the exportJSON() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();