This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type AddPrefix<TKey, TPrefix extends string> = TKey extends string ? `${TPrefix}${TKey}` : never | |
| type RemovePrefix<TPrefixedKey, TPrefix extends string> = TPrefixedKey extends AddPrefix<infer TKey, TPrefix> | |
| ? TKey | |
| : "" | |
| type PrefixedValue<TObject extends object, TPrefixedKey extends string, TPrefix extends string> = TObject extends { | |
| [K in RemovePrefix<TPrefixedKey, TPrefix>]: infer TValue | |
| } | |
| ? TValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.swap = function (idx1, idx2) { | |
| const temp = this[idx1]; | |
| this[idx1] = this[idx2]; | |
| this[idx2] = temp; | |
| } | |
| function rearrange(str) { | |
| const weightMap = str.split("").reduce((acc, curr) => { | |
| acc[curr] ? acc[curr] += 1 : acc[curr] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FunctifiedAsync { | |
| constructor(iterable) { | |
| this.iterable = iterable; | |
| } | |
| async *[Symbol.asyncIterator]() { | |
| for await (const value of this.iterable) { | |
| yield value; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function check_status_code { | |
| local name=$1 | |
| local status=$2 | |
| if [ $status -ne 0 ]; then | |
| echo $name failed with status code $status | |
| exit $status | |
| fi | |
| echo Success: $name with code $status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // use std::fmt; | |
| fn main() { | |
| let name = format!("shiv shankar"); | |
| let new_name :String ; | |
| println!("actual name = {:?}",name ); | |
| // shadow of name with mut | |
| let (mut name, title_name) = title_case(name); | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Node.js CheatSheet. | |
| // Download the Node.js source code or a pre-built installer for your platform, and start developing today. | |
| // Download: http://nodejs.org/download/ | |
| // More: http://nodejs.org/api/all.html | |
| // 0. Synopsis. | |
| // http://nodejs.org/api/synopsis.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var AWS = require('aws-sdk'); | |
| AWS.config.update({ | |
| accessKeyId: '{AWS_KEY}', | |
| secretAccessKey: '{AWS_SECRET}', | |
| region: '{SNS_REGION}' | |
| }); | |
| var sns = new AWS.SNS(); |