Skip to content

Instantly share code, notes, and snippets.

View olostan's full-sized avatar

Valentyn Shybanov olostan

View GitHub Profile
@olostan
olostan / db.js
Created April 2, 2014 08:12
Promisified Proxy-based MongoDB wrapper
var q = require('q');
var MongoClient = require('mongodb').MongoClient;
const dbUrl = require('./config').mongoUrl;
var dbConnection;
function getDb() {
if (dbConnection) return q(dbConnection);
@olostan
olostan / gist:11347165
Created April 27, 2014 14:37
pubspec.yaml
name: badges
description: A sample web application
dependencies:
angular: any
browser: any
transformers:
- angular
- $dart2js:
{'minify':true}
@olostan
olostan / gist:7a22213d7fd469c42d51
Created June 10, 2014 13:10
Invoke some function with injection from console
angular.element(document.body).injector().invoke(function($http) { $http.get('/api/').then(console.log.bind(console),console.error.bind(console))})
@olostan
olostan / gist:f0f428cd2d40b8af715c
Created June 11, 2014 09:37
How to run new module from console on opened AngularJS page
angular.module('test2',[]).run(function($http) { $http.get('/api/').then(console.log.bind(console),console.error.bind(console))});
angular.bootstrap( document.createElement("div"),['test2'])
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
var fs = require('fs');
var cheerio = require('cheerio');
var Chance = require('chance');
var chance = new Chance();
function getRandomData(type, hint) {
if (type == 'number') {
return (Math.random() * 1000000 | 0) / 100;
} else if (type == 'boolean') {
return Math.random() >= 0.5;
'use strict';
app
.directive('twfTransferToScope', function () {
return {
restrict: 'E',
link: function (scope, element, attr) {
element.hide();
scope[attr.name] = angular.fromJson(element.text());
}
@olostan
olostan / index.js
Created August 6, 2014 13:43
Bundles support in gulp plugin angular-file-sort
var es = require('event-stream');
var ngDep = require('ng-dependencies');
var toposort = require('toposort');
var ANGULAR_MODULE = 'ng';
module.exports = function angularFilesort (bundleFilter) {
var files = [];
var angmods = {};
var toSort = [];
@olostan
olostan / decorator.dart
Created April 19, 2015 08:29
"sample" Decorator for DaCSS
@Decorator(selector:'[sample]')
class Sample implements AttachAware{
Element _element;
Http _http;
Sample(this._element, this._http);
var sanitizer = const HtmlEscape();
Future<String> getFromDOM(String id) {
var sample = document.querySelector(id);
@olostan
olostan / routeTransitions.js
Last active August 29, 2015 14:20
routeTransitions for new Angular router
function setupHooks(controller) {
controller.prototype.deactivate = ['$scope',function($scope) {
console.log("deactivating",$scope);
}];
controller.prototype.canActivate = ['routeTransitions','$timeout',function(routeTransitions,$timeout) {
console.log("activating",routeTransitions.sourceElement);
var source = routeTransitions.sourceElement;
if (source) {
routeTransitions.sourceElement = null;
var cloneE = source[0].cloneNode(true);