Skip to content

Instantly share code, notes, and snippets.

View orhanveli's full-sized avatar

orhan orhanveli

  • Finbyte GmbH
  • Turkiye
  • 11:38 (UTC +03:00)
View GitHub Profile
@Eomerx
Eomerx / validate-tc-id.js
Last active October 13, 2022 17:47
Validate TC ID
//=======================================
// CHECK TC ID =
//=======================================
var checkTcNum = function(value) {
value = value.toString();
var isEleven = /^[0-9]{11}$/.test(value);
var totalX = 0;
for (var i = 0; i < 10; i++) {
totalX += Number(value.substr(i, 1));
}
@orhanveli
orhanveli / enum.php
Created October 29, 2014 12:25
php enum implementations
/***
* Class DfTypedEnum
*
* http://stackoverflow.com/a/15010599/287084
*
*/
abstract class TypedEnum
{
/** @var array cache of all enum instances by class name and integer value */
@orhanveli
orhanveli / scroll-to-elem.js
Created October 14, 2014 13:23
jQuery smooth scroll to element
function scrollToElement(selector) {
var $elem = $(selector);
if ($elem.length == 0) {
return;
}
var offsetTop = $elem.offset().top;
$('html,body').animate({
"scrollTop": offsetTop
@ridvanucok
ridvanucok / vergi_daireleri.sql
Created October 7, 2014 23:22
Türkiye Vergi Daireleri Veri Tabanı // Turkey Tax Departments Database
CREATE TABLE `vergi_daireleri` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`plaka` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`il` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ilce` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`daire` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
INSERT INTO vergi_daireleri (id, plaka, il, ilce, daire) VALUES (1, '01', 'ADANA', 'Merkez', '5 Ocak Vergi Dairesi Müdürlüğü');
@chris-rock
chris-rock / crypto-ctr.js
Last active November 10, 2020 02:27
Encrypt and decrypt text in nodejs
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption with CTR
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(text){
var cipher = crypto.createCipher(algorithm,password)
var crypted = cipher.update(text,'utf8','hex')
@moon0326
moon0326 / gist:352404802a4a37517771
Last active April 27, 2016 11:17
PHP Deployer Laravel sample
<?php
require_once 'recipe/common.php';
server('production', 'server ip', 'port (optional)')
->user('deploy')
->path('Path');
set('shared_dirs',['app/storage']);
set('shared_files',[]);
@kelvinn
kelvinn / cmd.sh
Created July 24, 2014 02:55
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@maephisto
maephisto / Javascript ISO country code to country name conversion
Last active November 6, 2025 09:27
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@akhoury
akhoury / handlebars-helper-x.js
Last active September 9, 2025 22:14
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " name == 'Sam' && age === '12' " }}
BOOM
@xasima
xasima / gist:7825313
Last active December 30, 2015 11:49
The log of testing the `grunt server` command when using yoman's generator-closure
weblab@devbox:~/projects$ grunt --version
grunt-cli v0.1.11
weblab@devbox:~/projects$ yo --version
1.0.4
weblab@devbox:~/projects/closure-test$ node --version
v0.8.26
weblab@devbox:~/projects/closure-test$ npm --version