Skip to content

Instantly share code, notes, and snippets.

View defiant's full-sized avatar
💭
I may be slow to respond.

Sinan Taga defiant

💭
I may be slow to respond.
View GitHub Profile
@defiant
defiant / dynamic-component.vue
Last active November 26, 2019 11:36
dynamic-component.vue
<template>
<div class="card">
<component v-bind:is="componentFile"></component>
</div>
</template>
<script>
export default{
props: {
componentName: {
type: String,
@defiant
defiant / verifyVkn.js
Last active December 4, 2020 12:42
Vergi Kimlik Numarası (VKN) doğrulama.
function verifyVkn(vkn) {
if (typeof vkn !== 'string') throw new TypeError('vkn should be a string');
if (vkn.length !== 10) throw new TypeError('invalid length');
const digits = vkn.split('');
const control = digits.pop(); // eslint-disable-line
const r = [];
digits.forEach((el, i) => {
@defiant
defiant / objectifyByKey.js
Created May 29, 2019 15:41
create and object from an array using the given key
function objectifyByKey(arr, key) {
if (!Array.isArray(arr)) throw new Error('not an array');
if (!arr.length) return;
const reducer = (acc, el) => {
if (Object.prototype.hasOwnProperty.call(key, el)) {
return { ...acc, [el[key]]: el };
}
return {};
};
@defiant
defiant / imp2vp.js
Created August 27, 2013 22:40
World Bridge Federation new IMP to VP scale implementation in Javascript
(function(){
var tau,
denom;
tau = (Math.sqrt(5)-1)/2;
denom = 1 - Math.pow(tau, 3);
var V = [], i=0;
var B = 15 * Math.sqrt(8); // test for 8 Boards
@defiant
defiant / crontab
Last active December 17, 2015 12:49
Sql dump shell script. Put this in cron and it automatically dumps you table at given intervals.
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
@defiant
defiant / luhn.js
Created March 19, 2013 15:42
Simple JS function. Returns true or false if the giving string passes Luhn Algorithm requirements.
<script>
var luhnNo = '79927398711';
function luhn(num){
var numArr = num.split(''),
tempInt,
odd = 0,
even = 0;
numArr.reverse();
@defiant
defiant / luhn.php
Created March 8, 2013 21:50
Checks a number and returns true if it validates according to Luhn Algorithm
/**
* Valid Luhn Number Checker
*/
class Luhn
{
static public function valid($num)
{
$odd = 0;
@defiant
defiant / MacOsX Context Cleaner
Last active October 13, 2015 07:08
Clear duplicates from the "open with" context menu on Mac OS X Mountain Lion
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user