Skip to content

Instantly share code, notes, and snippets.

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

Vivek Kumar Bansal vkbansal

💭
I may be slow to respond.
View GitHub Profile
@vkbansal
vkbansal / transform.ts
Created September 23, 2019 16:50
[TS tranformer] TS tranformer for codemod #typescript #codemod #ast
function transformer<T extends ts.Node>(): ts.TransformerFactory<T> {
return context => {
const visit: ts.Visitor = node => {
switch (node.kind) {
case ts.SyntaxKind.Parameter:
if (!(node as any).type) {
const newNode = ts.createParameter(
(node as ts.ParameterDeclaration).decorators,
(node as ts.ParameterDeclaration).modifiers,
(node as ts.ParameterDeclaration).dotDotDotToken,
@vkbansal
vkbansal / snippets.sh
Last active September 18, 2019 13:53
[Bash Snippets] Quick & dirty bash snippets #bash #snippets
# remove all the git branches with update in it
git rmf $(git ls | grep update | tr '\n' ' ')
# get version from package.json. may not work with 1.0.0-alpha.1
PKG_VERSION=$(node -e "console.log(require('./package.json').version);")
MAJOR_VERSION="$(echo $PKG_VERSION | cut -d "." -f 1)"
MINOR_VERSION="$(echo $PKG_VERSION | cut -d "." -f 2)"
PATCH_VERSION="$(echo $PKG_VERSION | cut -d "." -f 3)"
# vscode tab issue fix
@vkbansal
vkbansal / .gitignore
Last active April 17, 2019 14:45
Printing TypeScript code from AST
node_modules
// run this before
// npm run eslint > lint.log
const fs = require('fs');
let data = fs.readFileSync('./lint.log', 'utf8');
let output = {};
for (let line of data.split('\n')) {
@vkbansal
vkbansal / artisan.php
Created March 12, 2015 12:31
Tying to use artisan migrate commands outside laravel
<?php
require_once "vendor/autoload.php";
use Symfony\Component\Console\Application;
use Illuminate\Database\Console\Migrations;
use Pimple\Container;
$container = new Container();
$container['migration-table'] = 'migration';
@vkbansal
vkbansal / README.md
Last active August 29, 2015 14:06 — forked from mbostock/.block
Responsive D3 chart

Chord diagrams show directed relationships among a group of entities. This example also demonstrates simple interactivity by using mouseover filtering. Layout inspired by Martin Krzywinski's beautiful work on Circos.