Skip to content

Instantly share code, notes, and snippets.

View scriptjumper's full-sized avatar
🎯
Focusing

Shaeen Singh scriptjumper

🎯
Focusing
View GitHub Profile
@scriptjumper
scriptjumper / removing-object-properties.js
Created August 14, 2023 15:54
You can remove sensitive data from data from your objects using destructuring!
const userData = {
name: "John Doe",
email: "john.doe@tdd.com",
superSecretKey: "JOHNDOESECRETKEY"
}
const { superSecretKey, ...secureData } = userData;
console.log(secureData);
#!/bin/sh
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
@scriptjumper
scriptjumper / vscode-extensions.txt
Last active September 13, 2023 17:59
VS Code Extensions I recommend
dys8.jest-snippets
christian-kohler.npm-intellisense
christian-kohler.path-intellisense
CoenraadS.bracket-pair-colorizer
dbaeumer.vscode-eslint
esbenp.prettier-vscode
formulahendry.auto-rename-tag
glitch.glitch
JamesBirtles.svelte-vscode
joelday.docthis
@scriptjumper
scriptjumper / ago-counter.js
Created August 27, 2021 06:16
Counting the ages that is greater or equal to 50
const https = require("https");
https.get("https://coderbyte.com/api/challenges/json/age-counting", (resp) => {
resp.setEncoding("utf-8");
let data = "";
// parse json data here...
resp.on("data", (d) => {
data += [d];
});
@scriptjumper
scriptjumper / camelize.js
Created August 27, 2021 06:14
Converting a string into camel case
function camelize(str) {
let _str = str.toLowerCase();
var finalResult = _str.charAt(0).toUpperCase() + _str.slice(1);
return finalResult.replace(/\W+(.)/g, function (match, chr) {
return chr.toUpperCase();
});
}
console.log(camelize("cats AND*Dogs-are Awesome"));
@scriptjumper
scriptjumper / aws-sns-publish.js
Created April 17, 2020 20:50
Using aws sns service to post messages
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
exports.handler = function(event, context) {
console.log("\n\nLoading handler\n\n");
var sns = new AWS.SNS();
sns.publish({
Message: 'Test publish to SNS from Lambda',
TopicArn: 'TOPIC_ARN'
@scriptjumper
scriptjumper / csv_row_split.sh
Created April 17, 2020 20:45
splits the data in the spread sheet by 2000 items per sheet
echo "Extracting 2000 rows at a time"
split -l 2000 sheet.csv
echo "converting extracted files to csv format"
for i in *; do mv "$i" "$i.csv"; done
@scriptjumper
scriptjumper / dynamoDB.js
Created April 17, 2020 20:42
AWS lambda function to post data received from the app into dynamoDB table
var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
exports.handler = function (e, ctx, callback) {
var params = {
TableName: '<tablename>',
Item: 'table column data goes here'
};
@scriptjumper
scriptjumper / clear-heroku-cache.sh
Created March 28, 2020 07:30
Cleaning heroku app cache
# this shell script is used to clean up the cache of any heroku app listed below
echo "Enter the name of the heroku app that you would like to clear(make sure app name is the same as it is on heroku)."
read INPUT_STRING
heroku repo:gc --app $INPUT_STRING
heroku repo:purge_cache --app $INPUT_STRING
echo
echo
// add this in you Browserstack config files
beforeSession: function (config, capabilities, specs) {
capabilities.name = specs && specs[0].split('/').pop() || undefined;
}