Skip to content

Instantly share code, notes, and snippets.

View TMaYaD's full-sized avatar

Subhash Chandra TMaYaD

View GitHub Profile
@TMaYaD
TMaYaD / util.py
Created April 5, 2019 05:36
luigi include_params_from
_all_params_ = object()
class include_params_from(object):
"""
Task parameter copy.
It also takes two optional parameters: `only` and `omit`.
If `only` is provided, only the parameters given in `only` will be copied.
If `omit` is provided, parameters given in `omit` will not be copied.
Usage:
@TMaYaD
TMaYaD / challange-2.md
Last active April 19, 2018 11:24
Lexent Bio: Coding challange

S3-Gallery

Create a web-app to display images from an AWS s3 bucket as a gallery and add ratings to the images.

Notes:

  • The gallery should reflect the same folder structure as the s3 bucket with '/' as folder separator.
  • The s3 bucket should not be modified in any way. Assume read only permissions to the bucket.
  • Any external modifications like addition or deletion of the images should be reflected in the Gallery
  • The Gallery should allow rating the images with 0-5.
@TMaYaD
TMaYaD / lorem_ipsum.sh
Created September 8, 2017 13:37
Lorem Generator
#!/bin/sh
OK=0
if [ $# -eq 2 ] || [ $# -eq 3 ]; then
if [ "$1" = "-w" ]; then
LOREM_TYPE="words"
OK=1
fi
if [ "$1" = "-p" ]; then
LOREM_TYPE="paras"
package gorm_test
import (
"errors"
"github.com/jinzhu/gorm"
"reflect"
"testing"
"time"
@TMaYaD
TMaYaD / pre-build
Created October 28, 2014 21:23
install sqlite3 in dokku
#!/bin/bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
IMAGE="dokku/$1"
PLUGIN_DIR=$(dirname $0)
echo "-----> Injecting sqlite3 ..."
Fion.deleteItem = function (contentName) {
var asin = contentName.substring(11); // asin extracted from the argument
var itemData = itemCache.getDataByASIN(asin); // the item in the library list
// create vars to be sent in the ajax request to fiona-delete
var lendingId = '';
var lendingType = '';
var lendingStatus = '';
var loanId = '';
// assign the above vars where appropriate
if (itemData.loanId) {
@TMaYaD
TMaYaD / base.rb
Created November 16, 2012 07:12
ActiveModel like interface for redis
# lib/redis_record/base.rb
module RedisRecord::Base
extend ActiveSupport::Concern
def save
run_callbacks :save do
success = REDIS.multi do
REDIS.mapped_hmset(key, attributes)
sorted_indices.each do |attr|
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties -y
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm -y
# Install git to get statsd
sudo apt-get install git -y
101 def parse_and_update(file_name)$
102 Rails.logger.info "============================== Parsing: #{file_name} Begin =============================="$
103 piper, pipew = IO.pipe$
104 Thread.new do$
105 begin$
106 @remote_archive.get(file_name) do |chunk|$
107 puts chunk$
108 pipew << chunk$
109 end$
110 rescue Exception => e$
@TMaYaD
TMaYaD / node.json
Created April 30, 2012 08:17
chef attributes for test role
{ "run_list": "role[data_provider]" }