Skip to content

Instantly share code, notes, and snippets.

View talamaska's full-sized avatar

Zlati Pehlivanov talamaska

View GitHub Profile
@talamaska
talamaska / registrar.js
Created November 10, 2012 14:50 — forked from mheadd/registrar.js
A simple SIP registrar that uses Node.js and Redis
var sip = require('sip');
var sys = require('sys');
var redis = require('redis');
//Trim leading and trailing whitespace from string values.
function trim(str) {
return str.replace(/^\s+|\s+$/g, '');
}
sip.start({},function(request) {
$(function() {
var converter = new Showdown.converter();
$("#user_input").keyup(function(){
var txt = $("#user_input").val();
var html = converter.makeHtml(txt);
$("#result").html(html)
$("#html_result").val(html.replace(/>/g, ">\n").replace(/</g, "\n<").replace(/\n{2,}/g, "\n\n"));
});
var sample = "#### Underscores\nthis should have _emphasis_\nthis_should_not\n_nor_should_this\n\n\
<html>
<head>
<script>
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Holy Grail</title>
<style>
/* some basic styles. nothing to do with flexbox */
header, footer,
nav, article, aside {
border: 1px solid black;
@talamaska
talamaska / maintain-ratio.scss
Created February 12, 2016 10:38 — forked from brianmcallister/maintain-ratio.scss
Sass mixin for a responsive box that maintains an aspect ratio.
// Maintain ratio mixin. Great for responsive grids, or videos.
// https://gist.github.com/brianmcallister/2932463
//
// $ratio - Ratio the element needs to maintain.
//
// Examples
//
// // A 16:9 ratio would look like this:
// .element {
// @include maintain-ratio(16 9);
/* global: indexedDB, IDBKeyRange */
// index.js
// Provides easy interaction with indexedDB
// ---
// Part of the Riggr SPA framework <https://github.com/Fluidbyte/Riggr> and released
// under the MIT license. This notice must remain intact.
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
@talamaska
talamaska / BaseForm.ts
Created May 23, 2017 11:55 — forked from sasxa/BaseForm.ts
Angular2 Forms with @ngrx/store
export class _BaseForm {
_builder: FormBuilder;
_group: ControlGroup;
public controls = (value: any = {}) => ({
});
public selector: string = "examples";
public store: Store<any>;
constructor() { }
import { Component, forwardRef, Renderer2, ViewChild } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export const EPANDED_TEXTAREA_VALUE_ACCESSOR : any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => TextareaExpandedComponent),
multi: true,
};
@Component({
import { Directive, ElementRef, forwardRef, Input, Renderer2 } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { merge } from 'rxjs/observable/merge';
import { timer } from 'rxjs/observable/timer';
import { Subscription } from 'rxjs/Subscription';
export const DEFAULT_VALUE_ACCESSOR : any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NgControlOptionsDirective),