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 / 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.

@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';
// 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 / .gitignore
Last active April 17, 2019 14:45
Printing TypeScript code from AST
node_modules
@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 / 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 / context-01.tsx
Last active January 11, 2022 09:48
String Externalisation Snippets
// StringsContext.tsx
import { createContext } from "react";
// initialize the context
const StringsContext = createContext({});
// props for StringsContextProvider
export interface StringsContextProviderProps {
data: Record<string, any>;
}
// a wrapper for `StringsContext.Provider` for better API
export function StringsContextProvider(
@vkbansal
vkbansal / strings.d.ts
Created January 11, 2022 09:38
strings-ext-02
// strings.yaml.d.ts
declare const strings: Record<string, string>;
export default strings;
@vkbansal
vkbansal / strings.yaml
Created January 11, 2022 09:40
string-ext-03
homePageTitle: Home
aboutPageTitle: About
homePageContent:
para1: |
Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquam, eos
animi. Corporis harum quaerat dicta possimus illum aut unde laborum
excepturi suscipit quibusdam perspiciatis dolorum alias, exercitationem
similique illo? Distinctio.
para2: |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit