Skip to content

Instantly share code, notes, and snippets.

<?php
//class FlightTree implements ArrayAccess, Traversable {
class FlightTree {
private $key;
private $data = NULL;
private $children = array();
private $parent;
@refo
refo / parse-telefon.js
Last active September 27, 2022 10:32
Türkiye telefon numarası parse et.
var input = " + 9 0 asdas (532) 123 - 45 6 7 ";
var telefon = input.replace(/(^\D*9?\D*0|\D+)/ig, '');
console.log(telefon);
// Şunu yazdırır:
// 5321234567
//
// Çıktı 10 karakter ise, numara doğru kabul edilebilir.
@refo
refo / 0_reuse_code.js
Created September 14, 2016 21:19
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
@refo
refo / git-snippets.md
Last active September 4, 2018 11:44
Git Command Snippets

Clone single branch and latest commit only

git clone --single-branch --depth 1 -b BRANCH REPO

Compate two branches and print what's merged into first branch ahead of the second branch

LEFT="branch-1"; \
RIGHT="branch-2"; \
@refo
refo / namecheap-domains.txt
Created October 30, 2016 12:09
Namecheap scrape domain list and expiration dates
// #maincontent > div > div.dl-wrapper.normal-view > div > div:nth-child(2) > div > table > tbody:nth-child(3) > tr:nth-child(1) > td.domain-name.form > p:nth-child(2) > strong
// #maincontent > div > div.dl-wrapper.normal-view > div > div:nth-child(2) > div > table > tbody:nth-child(3) > tr:nth-child(1) > td.expiring > p > b
var list = $('#maincontent > div > div.dl-wrapper.normal-view > div > div:nth-child(2) > div > table tr.item')
.map(function(idx, item){
return {
'domain': $('td.domain-name.form > p:nth-child(2) > strong', item).text(),
'expiring': $('td.expiring > p > b', item).text()
@refo
refo / geolocation.js
Created November 15, 2016 18:14
Javascript GeoLocation
navigator.geolocation.getCurrentPosition(function(geopos){
var coords = geopos.coords;
console.log('https://maps.google.com/?q='+coords.latitude+','+coords.longitude);
});
@refo
refo / selectAll.html
Last active August 3, 2017 13:17
Javascript, select all on click
<!-- Example Usage -->
<div class="form-group col-sm-6">
<label class="control-label">Link <sup class="alert-danger">*</sup></label>
<div ng-bind="item.url" onclick="selectAll(this);" class="form-control"></div>
</div>
@refo
refo / bash-filepath-parts.md
Last active February 2, 2024 11:57
Extract file name / file path parts using bash

Extract given file path into its parts

Assuming, file passed as a parameter

path=$1

following script will extract file path into parts

@refo
refo / foursquare_api_search.js
Created December 20, 2016 19:59
Foursquare Search API test
"use strict";
const
assert = require('assert'),
request = require('request'),
config = require('../config'),
_ = '';
const foursq = {
@refo
refo / React material-ui HOCs.md
Last active February 17, 2017 12:09
React material-ui HOCs

Dependencies

yarn add material-ui
yarn add vanilla-text-mask
yarn add text-mask-addons