Skip to content

Instantly share code, notes, and snippets.

View Meshugah's full-sized avatar
🌴

Vignesh Karthikeyan Meshugah

🌴
View GitHub Profile
const {createStore} = require('redux')
// Actions are mapped to state here, called a Reducer
function setIntervalState(state= 0, action) {
switch(action.type){
case 'START_TIMER':
return state = action.payload
case 'STOP_TIMER':
if(state !== 0)
@Meshugah
Meshugah / gist:8876af64288e16f5a463802dde92839f
Created July 4, 2020 13:52
Great Link for lambda calculus
https://plato.stanford.edu/entries/lambda-calculus/
@Meshugah
Meshugah / invertPDF
Created June 24, 2020 05:53
Invert PDF gist
gs -o inverted.pdf \
-sDEVICE=pdfwrite \
-c "{1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer" \
-f input.pdf
@Meshugah
Meshugah / Flutterhelp
Last active June 4, 2020 05:39
Flutterhelp code review
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:syncfusion_flutter_core/core.dart';
void main() {
return runApp(MyApp());
}
class MyApp extends StatelessWidget {
// // All rounded up values in kilos
// itemTransferMinimums = {
// 'Fastner': '2000'
// }
// function myround(x, roundUp){
// return base * Math.ceil(x/roundUp);
// }
// frappe.ui.form.on('Stock Entry', {
@Meshugah
Meshugah / frappe
Last active April 16, 2020 14:00
Frappe - get from db/get BOM + insert a doc + set_value + frappe.call + submit a saved doc + get_doc + auto-submit example + all doctypes
frappe.db.get_list('BOM')
frappe.db.insert({
doctype: 'Stock Entry',
stock_entry_type: 'Material Receipt',
items: [
{
'item_code': '0002',
'item_name': 'Spring Clip',
'schedule_date': '30 - 11 - 2021',
@Meshugah
Meshugah / Factory.sol
Last active October 19, 2019 11:21
Centralized Gas Wallet
pragma solidity ^0.5.8;
/*
Just the interface so solidity can compile properly
We could skip this if we use generic call creation or abi.encodeWithSelector
*/
contract ERC20 {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
@Meshugah
Meshugah / bitcoinHD.js
Created September 11, 2019 14:01
Bitcoin HD wallet implementation in node.
const bip39 = require("bip39");
const hdkey = require("hdkey");
const createHash = require("create-hash");
const bs58check = require("bs58check");
const mnemonic = bip39.generateMnemonic(); //generates string
const seed = bip39.mnemonicToSeedSync(mnemonic).toString('hex'); //creates seed buffer
const root = hdkey.fromMasterSeed(seed);
@Meshugah
Meshugah / ethereumHD.js
Created September 11, 2019 12:51
Sample HD wallet for Ethereum
const bip39 = require("bip39"); // mnemonic generator
const hdkey = require("hdkey"); // wallet lib
const ethUtil = require("ethereumjs-util"); // Used here for public address and public key generation
const mnemonic = bip39.generateMnemonic(); // generates string
const seed = bip39.mnemonicToSeedSync(mnemonic).toString('hex'); // creates seed for wallet
const root = hdkey.fromMasterSeed(seed);
const masterPrivateKey = root.privateKey.toString('hex');