Skip to content

Instantly share code, notes, and snippets.

View noppolp's full-sized avatar

noppolp noppolp

View GitHub Profile
@noppolp
noppolp / event-emitter-sample.js
Created May 18, 2015 16:25
EvenEmitter on NodeJS
var EventEmitter = require('events').EventEmitter;
var doSomething = function () {
var result = new EventEmitter();
setTimeout(function () {
result.emit('success', 'Hello World!');
}, 1000);
return result;
};
@noppolp
noppolp / restlerapp.js
Created May 17, 2015 09:24
Upload file using restler
var rest = require('restler');
var FileInfo = require('./FileInfo.js');
var file = new FileInfo([FULL PATH OF YOUR FILE]);
rest.post([API_ULR], {
multipart: true,
data: {
file: rest.file(file.fullPath, file.name, file.size, null, file.contentType)
},
@noppolp
noppolp / FileInfo.js
Created May 17, 2015 09:11
FileInfo for NodeJS
var fs = require('fs');
var path = require('path');
var mime = require('mime');
var FileInfo = function (fullPath) {
if (fs.existsSync(fullPath)) {
this.fullPath = fullPath;
var stats = fs.statSync(fullPath);
this.size = stats["size"];
this.name = path.basename(fullPath);
@noppolp
noppolp / WorkerRole.cs
Created May 15, 2015 07:50
WorkerRole with Face API sdk
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage;
@noppolp
noppolp / cron
Created May 14, 2015 10:06
cron command
# view log
$ sudo grep cron /var/log/syslog
# restart
$ sudo service cron restart
# edit crontab
$ crontab -e
# list crontab
@noppolp
noppolp / ticktotime.php
Created May 13, 2015 16:48
Convert DateTime.Ticks into PHP time() and convert back
public static function TicksToTime($tick){
return floor(($ticks - 621355968000000000) / 10000000);
}
public static function TimeToTicks($time){
return number_format(($time * 10000000) + 621355968000000000 , 0, ’.’, “);
@noppolp
noppolp / MainPage.xaml.cs
Created May 9, 2015 11:17
Smooth Streaming on MainPage.xaml.cs
using Microsoft.Media.AdaptiveStreaming;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@noppolp
noppolp / mainpage.xml
Created May 9, 2015 11:15
MediaElement in MainPage.xml
<Page
x:Class="SmoothStreamingWP81.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmoothStreamingWP81"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@noppolp
noppolp / smoothstream.xml
Created May 9, 2015 11:13
Smooth Streaming Package.appxmanifest
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
....
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
@noppolp
noppolp / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console