Skip to content

Instantly share code, notes, and snippets.

View seerahulsingh's full-sized avatar
🏠
Working from home

Rahul Singh seerahulsingh

🏠
Working from home
  • Varanasi
View GitHub Profile
@seerahulsingh
seerahulsingh / s3_folder_upload.rb
Created August 15, 2021 19:06 — forked from fleveque/s3_folder_upload.rb
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v2 gem, based on http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively/
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket, :include_folder
attr_accessor :files
# Initialize the upload class
@seerahulsingh
seerahulsingh / package.xml
Created May 26, 2021 17:12 — forked from shanerk/package.xml
Salesforce package.xml file to get all metadata from your org. Works great with vscode and cli.
<?xml version="1.0" encoding="UTF-8" ?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
@seerahulsingh
seerahulsingh / gist:c1a6bab85928d85c278b302a631e9e22
Created June 29, 2018 14:28 — forked from wrburgess/gist:5528649
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@seerahulsingh
seerahulsingh / application_controller.rb
Created April 27, 2018 05:47 — forked from jamesmartin/application_controller.rb
Testing ApplicationController before_filter methods using RSpec's "anonymous" controller instance
class ApplicationController < ActionControllerBase
helper :do_something
def do_something
@from_do_something = params[:for_do_something]
end
end
@seerahulsingh
seerahulsingh / rspec_model_testing_template.rb
Created February 6, 2018 16:19 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@seerahulsingh
seerahulsingh / youtube-dl-download-pluralsight.md
Created January 3, 2018 17:27 — forked from munim/youtube-dl-download-pluralsight.md
youtube-dl to download pluralsight videos

Download Plural Sight videos

Software required:

youtube-dl

After installation and putting the youtube-dl in PATH

youtube-dl \
@seerahulsingh
seerahulsingh / app.js
Created July 24, 2017 19:33 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@seerahulsingh
seerahulsingh / compressed_static_assets.rb
Created July 24, 2017 10:12 — forked from guyboltonking/compressed_static_assets.rb
Slightly hacky rails middleware for serving up precompiled gzipped assets
require 'action_dispatch/middleware/static'
module Middleware
class FileHandler < ActionDispatch::FileHandler
def initialize(root, assets_path, cache_control)
@assets_path = assets_path.chomp('/') + '/'
super(root, cache_control)
end
def match?(path)
@seerahulsingh
seerahulsingh / samplerest.js
Created December 14, 2016 09:12 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@seerahulsingh
seerahulsingh / gist:53a6c2ce0c885fce81f6eff241845f6b
Created December 5, 2016 11:43 — forked from cultofmetatron/gist:5349630
passport ajax capable authenticate
app.post('/login', function(req, res) {
console.log(res);
passport.authenticate('local', function(err, user) {
if (req.xhr) {
//thanks @jkevinburton
if (err) { return res.json({ error: err.message }); }
if (!user) { return res.json({error : "Invalid Login"}); }
req.login(user, {}, function(err) {
if (err) { return res.json({error:err}); }
return res.json(