Skip to content

Instantly share code, notes, and snippets.

View nikoloza's full-sized avatar
🌀
symbo.ls

Nika nikoloza

🌀
symbo.ls
View GitHub Profile
@nikoloza
nikoloza / data-href.html
Last active February 4, 2016 15:17
Making 'href' for any element
<!-- The original idea came from https://github.com/nathanford/data-href -->
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<section>
<p data-href="#/paragraph/url/">
@nikoloza
nikoloza / gruntfile.js
Last active June 4, 2016 23:51
Run any command on recently changed file via Grunt
'use strict'
module.exports = function (grunt) {
grunt.initConfig({
options: {
command: 'touch',
args: '',
filepath: '',
file: ''
},
@nikoloza
nikoloza / grid.less
Last active February 4, 2016 15:10
Generate simple Grid System using Less
.columns(@property: 1) {
& > .cell {
width: 100% / @property;
}
}
.generate-row(@n, @i: 1) when (@i =< @n) {
&.row@{i} {
.columns(@i);
}
@nikoloza
nikoloza / rot17.js
Last active March 15, 2016 03:38
ROT13 variation for Georgian Alphabet.
String.prototype.rot17 = function() {
return this.replace(/[ა-ჱ]/g, function(c) {
c = c.charCodeAt() + 17;
return String.fromCharCode(c <= 4337 ? c : c - 34);
});
};
@nikoloza
nikoloza / ngRedirectTo.js
Last active March 16, 2016 23:27
Angular ui-router redirectTo trick
// define app
angular.module('app', [])
// listen to state changes
.config(function($rootScope) {
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState) {
// redirectTo
if (toState.redirectTo) {
event.preventDefault();
$state.go(toState.redirectTo, toParams);
@nikoloza
nikoloza / ngCurrencyExchange.js
Last active May 2, 2024 02:29
[Depricated - it's no longer free] Universal currency exchanger in Angular.js using freecurrencyconverterapi.com public API (ES5)
app.service('CurrencyExchange', function($http, $q) {
// using public API for currency exchange rates
return function (from, rates) {
var deferred = $q.defer();
var base = from.toUpperCase();
var currencies = [];
if (typeof rates === 'string') {
currencies = base + '_' + rates.toUpperCase();
@nikoloza
nikoloza / md-server.js
Last active June 4, 2016 23:49
Use README.md file as a homepage for Express based services
var express = require('express')
var marked = require('marked')
var app = express();
// use README.md file as a homepage
app.get('/', function(req, res) {
res.set('content-type','text/html');
res.send(
'<style>' +
fs.readFileSync('./node_modules/github-markdown-css/github-markdown.css') +
@nikoloza
nikoloza / install.js
Last active September 12, 2016 09:59
installing Vigour repos and link them
'use strict'
var cp = require('child_process')
var fs = require('fs')
var installOthersSetting = true
var pull = true
const GLOBAL_MODULES = __dirname + '/hacked_node_modules'
// prop clean up nodemodules linkers -- else npm is become a problem
var mySetup = {
@nikoloza
nikoloza / parser.js
Last active September 12, 2016 09:59
Clean Vigour CSS from unwanted properties
var fs = require('fs')
var LineByLine = require('line-by-line')
var bundle = 'bundle.css'
var _bundle = '_bundle.css'
var file = 'new.less'
var _file = '_new.less'
var cleanRegEx = /^((\s+)?((\.|\@|\d).+|color|background|border|a|html|body|div|section|div|body|section|img|thumb|\:\:).+|((\s+)?\}))/m
var emptyRegEx = /^((.+\,\n)+)?(.+\{)(\n+|\s+)\}\n?/gm
@nikoloza
nikoloza / hackRandom.js
Last active October 10, 2016 20:20
I've heard Math.random() is based on timestamp. I wanted to check how we can predict it with maximum accuracy. So if that two numbers are close together (can be the same in multithreads maybe), we can definitely check and hack any system based on Math.random().
(function(interval){
const start = Date.now()
const end = start + 1000
let i = 0
function hackRandom () {
let now = Date.now()
if (now > end) {
console.log(`timestamp: ${now}`, `random: ${Math.random()}`)
i++
}