Skip to content

Instantly share code, notes, and snippets.

@samin
samin / RDSDataAPIClient.js
Last active December 19, 2021 08:50
RDS Data API
const Bluebird = require('bluebird');
const { isUndefined } = require('lodash');
const Client = require('knex/lib/dialects/mysql');
const Transaction = require('knex/lib/transaction');
const inherits = require('inherits');
const sqlstring = require('sqlstring');
class RDSDataAPITransaction extends Transaction {
@samin
samin / graphql-upload-lambda.js
Created June 19, 2019 18:16
Adapted jaydenseric/graphql-upload to work on a Lambda event. Based on https://github.com/jaydenseric/graphql-upload/blob/master/src/processRequest.mjs
const Busboy = require('busboy');
const { WriteStream } = require('fs-capacitor');
const objectPath = require('object-path');
const SPEC_URL = 'https://github.com/jaydenseric/graphql-multipart-request-spec';
const isObject = value => value && value.constructor === Object;
const isString = value => typeof value === 'string' || value instanceof String;
@samin
samin / web_design_challenge.md
Created February 15, 2017 18:16
ClassApp Web Design Challenge

Web Design Challenge

Build a new landing page (just initial page) for https://www.classapp.com.br. You can use Semantic UI, but it's not required. Send link and source code.

@samin
samin / dev_challenge.md
Last active May 28, 2018 13:33
ClassApp Dev Challenge

Dev Challenge

Create a program in Node.js where the input defined in input.csv is parsed and organised into the content shown in output.json.

Please write your program in only one file (like index.js) and write the output to a file (output.json) instead of printing it to logs or on the screen.

@samin
samin / result.js
Created December 23, 2015 19:08
Result
[{
fullname: "John Doe 1",
eid: "1234",
classes: [
"Sala 1",
"Sala 2",
"Sala 3",
"Sala 4",
"Sala 5",
"Sala 6"
@samin
samin / core.js
Last active August 29, 2015 14:01
/**
The MIT License (MIT)
Copyright (c) 2014 Samin Shams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
function get_mx($email)
{
// Get domain name from email
$domain = substr(strrchr($email, "@"), 1);
// get MX records for domain
getmxrr($domain, $mxhosts);
// Match records with three options
preg_match('/google|hotmail|yahoo/i', implode(' ', $mxhosts), $matches);
{
"pagination":{
"next":"https://api.readmill.com/v2/me/library?access_token=abc&offset=1&order=created_at&to=2013-05-06+10%3A11%3A04+UTC"
},
"items":[
{
"library_item":{
"id":1,
"created_at":"2012-08-13T15:23:37Z",
"state":"active",
@samin
samin / gist:5206809
Created March 20, 2013 17:47
Web App Startup Images for iOS Devices
<!-- iPhone - 320x460 -->
<link href="touch-startup-iphone.png"
media="(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 1)"
rel="apple-touch-startup-image">
<!-- iPhone (Retina) - 640x920 -->
<link href="touch-startup-iphone-retina.png"
media="(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 2)"
@samin
samin / gist:5205481
Last active December 15, 2015 04:59
Hide address bar from iPhone and Android browser
if (((/iphone/gi).test(navigator.userAgent) || (/ipod/gi).test(navigator.userAgent)) &&
(!("standalone" in window.navigator) && !window.navigator.standalone)) {
offset = 60;
$('body').css('min-height', (window.innerHeight + offset) + 'px');
setTimeout( function(){ window.scrollTo(0, 1); }, 1 );
}
if ((/android/gi).test(navigator.userAgent)) {
offset = 56;
$('html').css('min-height', (window.innerHeight + offset) + 'px');