Skip to content

Instantly share code, notes, and snippets.

Avatar

Pratik Khadloya tispratik

View GitHub Profile
@tispratik
tispratik / cuda_check.py
Created Feb 14, 2020 — forked from f0k/cuda_check.py
Simple python script to obtain CUDA device information
View cuda_check.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.
@tispratik
tispratik / override_cache_key.rb
Last active Sep 6, 2018
Override cache key and touch methods in active record when we cannot update the last modified / updated at column in database. We keep track of the changes in memcache.
View override_cache_key.rb
module CacheKeyMonkeyPatch
module ActiveRecord
module Integration
# Returns a cache key that can be used to identify this record.
#
# ==== Examples
#
# Product.new.cache_key # => "products/new"
# Product.find(5).cache_key # => "products/5" (updated_at / last_modified_time not available)
@tispratik
tispratik / hive 0.13 parquet import through hcatalog
Last active Feb 8, 2018
hive 0.13, parquet import through hcatalog
View hive 0.13 parquet import through hcatalog
sqoop-7e14e38$ bin/sqoop import -jt <jt> --connect jdbc:mysql://... --username user --password pwd --query "... WHERE \$CONDITIONS" --num-mappers 1 --hcatalog-storage-stanza "STORED AS PARQUET" --create-hcatalog-table --hcatalog-table abc116 --verbose
Warning: /hell does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/pkhadloya/sqoop-7e14e38/bin/../../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
14/09/19 11:33:09 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-SNAPSHOT
14/09/19 11:33:09 DEBUG tool.BaseSqoopTool: Enabled debug logging.
14/09/19 11:33:09 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
14/09/19 11:33:09 DEBUG sqoop.ConnFactory: Loaded manager factory: org.apache.sqoop.manager.oracle.OraOopManagerFactory
14/09/19 11:33:09 DEBUG sqoop.ConnFactory: Loaded manager factory: com.cloudera.sqoop.manager.De
View gist:2316649
# This patch is required:
# For: google authentication.
# When: Running rails on a port other than 80 where a proxy server proxies to rails.
# Cause: 1. Rack is not able to figure out that it should not set the realm url port to the rails custom port in case the full_host is mentioned using
# OmniAuth.config.full_host
# 2. OpenID tries to validate the incoming callback url with the custom port that rails is running on and throws the error "return_to #{meth.to_s} does not match".
env = Rails.env
if env != "development"
@tispratik
tispratik / parquet_columns_reader1.java
Last active Mar 15, 2017
Parquet columns reader1
View parquet_columns_reader1.java
package com.company.grid.lookup;
import parquet.column.ColumnDescriptor;
import parquet.column.ColumnReader;
import parquet.column.impl.ColumnReadStoreImpl;
import parquet.column.page.PageReadStore;
import parquet.hadoop.ParquetFileReader;
import parquet.hadoop.metadata.BlockMetaData;
import parquet.hadoop.metadata.ParquetMetadata;
import parquet.io.api.Binary;
View gist:02628943731d3e2eaf4e
Counting objects: 125, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (119/119), done.
Writing objects: 100% (125/125), 125.92 KiB | 0 bytes/s, done.
Total 125 (delta 85), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/HashNuke/heroku-buildpack-elixir... done
remote: -----> elixir app detected
View apache
## Canonical redirect for Apache
# BEGIN Canonical Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC] ## will match any domain that's not our main domain
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
# END Canonical Redirect
View application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def handle_unverified_request
super
raise ActionController::InvalidAuthenticityToken
end
View Berksfile
cookbook 'nginx-app', '~> 0.1.0', path: 'cookbooks/nginx-app'
View bootstrap-chef-solo.sh
#!/usr/bin/env bash
# Pre-requisites
apt-get -y update
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
# Download and compile Ruby 2.0.0-p247
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
You can’t perform that action at this time.