Removes a file
rm app.js
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
if (typeof window.DeviceMotionEvent != 'undefined') | |
{ | |
// Shake sensitivity (a lower number is more) | |
var sensitivity = 15; | |
// Position variables | |
var x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0; | |
// Listen to motion events and update the position | |
window.addEventListener('devicemotion', function (e) |
/* | |
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674 | |
*/ | |
var fs = require('fs'); | |
// string generated by canvas.toDataURL() | |
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0" | |
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" | |
+ "3gAAAABJRU5ErkJggg=="; | |
// strip off the data: url prefix to get just the base64-encoded bytes |
<?php | |
// requires php5 | |
define('UPLOAD_DIR', 'images/'); | |
$img = $_POST['img']; | |
$img = str_replace('data:image/png;base64,', '', $img); | |
$img = str_replace(' ', '+', $img); | |
$data = base64_decode($img); | |
$file = UPLOAD_DIR . uniqid() . '.png'; | |
$success = file_put_contents($file, $data); | |
print $success ? $file : 'Unable to save the file.'; |
drag: function () { | |
function startDrag(e) { | |
// determine event object | |
if (!e) { | |
var e = window.event; | |
} | |
if(e.preventDefault) e.preventDefault(); | |
// IE uses srcElement, others use target | |
targ = e.target ? e.target : e.srcElement; |
var maxWidth = 304; // Max width for the image | |
var maxHeight = 338; // Max height for the image | |
var ratio = 0; // Used for aspect ratio | |
var width = img.width; // Current image width | |
var height = img.height; // Current image height | |
var image = document.getElementById('userImage'); | |
image.style.width = width + 'px'; | |
image.style.height = height + 'px'; |
function getOrientation(file, callback) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
var view = new DataView(e.target.result); | |
if (view.getUint16(0, false) != 0xFFD8) return callback(-2); | |
var length = view.byteLength, offset = 2; | |
while (offset < length) { | |
var marker = view.getUint16(offset, false); | |
offset += 2; |
public function sendEmail($id,$password){ | |
$data = Login::find($id); | |
$message = "<p> | |
Thank you for registering with Ques Tag. | |
</p> | |
below is your login details | |
<p> | |
Email: ". $data['email']." | |
Password: ".$password." | |
</p> |
var video = document.getElementsByTagName('video')[0]; | |
//console.log(video.seekable.start(0)); | |
console.log(video.seekable); | |
//console.log(video.played.end(0)); | |
var i = setInterval(function() { | |
if(video.readyState > 0) { | |
var minutes = parseInt(video.duration / 60, 10); | |
var seconds = video.duration % 60; | |
console.log(minutes+':'+seconds); | |
// (Put the minutes and seconds in the display) |