Skip to content

Instantly share code, notes, and snippets.

View kosso's full-sized avatar

Kosso kosso

View GitHub Profile
// see: https://medium.com/reactnative/emojis-in-javascript-f693d0eb79fb
// http://www.2ality.com/2013/09/javascript-unicode.html
function toUTF16(codePoint) {
var TEN_BITS = parseInt('1111111111', 2);
function u(codeUnit) {
return '\\u'+codeUnit.toString(16).toUpperCase();
}
if (codePoint <= 0xFFFF) {
return u(codePoint);
@kosso
kosso / websocket-relay-secure.js
Created September 2, 2018 16:04
websocket-relay.js from JSMpeg slightly modified to use HTTPS instead of HTTP
// Use the websocket-relay to serve a raw MPEG-TS over WebSockets. You can use
// ffmpeg to feed the relay. ffmpeg -> websocket-relay -> browser
// Example:
// node websocket-relay yoursecret 8081 8082
// ffmpeg -i <some input> -f mpegts https://localhost:8081/yoursecret
var fs = require('fs'),
https = require('https'),
WebSocket = require('ws');
@kosso
kosso / angularjs_directive_attribute_explanation.md
Created September 21, 2017 15:12 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@kosso
kosso / API.php
Created August 6, 2017 17:41 — forked from mohamedsalehamin/API.php
Wp-Polls Rest Api Gist
<?php
/**********************************************************************
*
* Poll
*
**********************************************************************/
function get_poll_template_by_me($poll_id, $display_loading = true)
{
global $wpdb;
$data = array();
@kosso
kosso / fb-post-preview.directive.js
Created June 8, 2017 02:30 — forked from thachnuida/fb-post-preview.directive.js
Angular directive to embed Facebook public post
(function () {
'use strict';
/**
* @desc Direictive to embed facebook post
* @example <fb-post-preview data-href="vm.postUrl"></fb-post-preview>
*/
angular
.module('fbDirective')
.directive('fbPostPreview', fbPostPreview);
@kosso
kosso / svgfixer.js
Created March 28, 2017 15:20 — forked from leonderijke/svgfixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@kosso
kosso / rPi3-ap-setup.sh
Created March 11, 2016 00:08 — forked from Lewiscowles1986/rPi3-ap-setup.sh
Raspberry Pi 3 access-point-setup
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
if [[ $# -ne 1 ]];
then echo "You need to pass a password!"
echo "Usage:"
# Add multimedia source
echo "deb http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
echo "deb-src http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
apt-get update
apt-get install deb-multimedia-keyring # if this aborts, try again
apt-get update
# Go to local source directory
cd /usr/local/src
@kosso
kosso / app.js
Created July 16, 2012 11:52
titanium tiws module example
// ****************************************************************************************************************
// ****************************************************************************************************************
// test value can be 'raw' | 'socket.io' | 'nowjs'
var test = 'raw',
// ****************************************************************************************************************
// ****************************************************************************************************************
// REMEMBER to change this with your data
@kosso
kosso / uri.js
Created April 25, 2012 19:27 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"