Skip to content

Instantly share code, notes, and snippets.

@techslides
techslides / convert.js
Created April 3, 2015 21:13
HML5 Canvas to WebM Video with JavaScript
//Whammy: https://github.com/antimatter15/whammy
window.Whammy=(function(){function toWebM(frames,outputAsArray){var info=checkFrames(frames);var CLUSTER_MAX_DURATION=30000;var EBML=[{"id":0x1a45dfa3,"data":[{"data":1,"id":0x4286},{"data":1,"id":0x42f7},{"data":4,"id":0x42f2},{"data":8,"id":0x42f3},{"data":"webm","id":0x4282},{"data":2,"id":0x4287},{"data":2,"id":0x4285}]},{"id":0x18538067,"data":[{"id":0x1549a966,"data":[{"data":1e6,"id":0x2ad7b1},{"data":"whammy","id":0x4d80},{"data":"whammy","id":0x5741},{"data":doubleToString(info.duration),"id":0x4489}]},{"id":0x1654ae6b,"data":[{"id":0xae,"data":[{"data":1,"id":0xd7},{"data":1,"id":0x73c5},{"data":0,"id":0x9c},{"data":"und","id":0x22b59c},{"data":"V_VP8","id":0x86},{"data":"VP8","id":0x258688},{"data":1,"id":0x83},{"id":0xe0,"data":[{"data":info.width,"id":0xb0},{"data":info.height,"id":0xba}]}]}]},{"id":0x1c53bb6b,"data":[]}]}];var segment=EBML[1];var cues=segment.data[2];var frameNumber=0;var clusterTimecode=0;while(frameNumber<frames.length){var cueP
@techslides
techslides / wp-ajax-upload.php
Last active November 26, 2020 14:15
Upload to WordPress with Ajax and FormData
<input type="file" name="file" id="file">
<input type="submit" id="submit" name="Upload" onclick="upload();return false;">
<script type="text/javascript">
function upload(){
var formData = new FormData();
formData.append("action", "upload-attachment");
var fileInputElement = document.getElementById("file");
formData.append("async-upload", fileInputElement.files[0]);
{
"Afghanistan": "Asia",
"Aland Islands": "Europe",
"Albania": "Europe",
"Algeria": "Africa",
"Andorra": "Europe",
"Angola": "Africa",
"Anguilla": "North America",
"Antigua and Barbuda": "North America",
"Argentina": "South America",
@techslides
techslides / slideshare-upload.php
Created November 4, 2014 22:20
Slide Upload with SlideShare API and PHP cURL
<?php
//user provided settings
$apikey = 'API-KEY';
$secret = 'SECRET';
$username = 'USERNAME';
$password = 'PASSWORD';
$title = "YOUR-TITLE";
$file = rawurlencode('URL-TO-FILE');
$public = "Y";
@techslides
techslides / pinterest-sort-likes.js
Last active May 10, 2016 03:33
Auto Sort Pinterest Pins by Likes
//Go to any page with pins (a board, your pins, search results, etc) and open JavaScript Console (Ctrl+Shift+J on windows OR option+command+J on mac) and paste in this code:
//sort by likes, adjust amount of pins/pages you want to collect first
var pages = 5;
var count = 0;
var mylist = [];
var timeout;
load();
function load(){
@techslides
techslides / pinterest-sort-repins.js
Created November 3, 2014 18:42
Auto Sort Pinterest Pins by Repins
//Go to any page with pins (a board, your pins, search results, etc) and open JavaScript Console (Ctrl+Shift+J on windows OR option+command+J on mac) and paste in this code:
//sort by repins, adjust amount of pins/pages you want to collect first
var pages = 5;
var count = 0;
var mylist = [];
var timeout;
load();
function load(){
@techslides
techslides / save.php
Created October 20, 2014 19:15
Save Ajax POST data as a file with PHP
<?php
//error_reporting(E_ALL);
//var_dump($_SERVER);
$post_data = $_POST['data'];
if (!empty($post_data)) {
$dir = 'YOUR-SERVER-DIRECTORY/files';
$file = uniqid().getmypid();
$filename = $dir.$file.'.txt';
$handle = fopen($filename, "w");
fwrite($handle, $post_data);
@techslides
techslides / index.html
Created October 20, 2014 19:09
HTML Ajax POST call to PHP
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Save Data with Ajax and PHP</title>
</head>
<body>
<textarea id="data">Enter some content here you want to save as a file</textarea>
<button id="save" onclick="save();return false;">Save</button>
<div id="response"></div>
@techslides
techslides / form3.js
Created October 16, 2014 21:01
HTML Form POST Submit via Ajax to Node.js
// Load the http module to create an http server.
var http = require('http');
// Create a function to handle every HTTP request
function handler(req, res){
var form = '';
if(req.method == "GET"){