Skip to content

Instantly share code, notes, and snippets.

View silent-vim's full-sized avatar
🎯
Focusing

Dhruv Arya silent-vim

🎯
Focusing
View GitHub Profile
@Cediddi
Cediddi / pg10_partition_compiler_sqla.py
Last active September 12, 2019 16:44
Simple helper that enables Postgresql 10's declarative partitioning features.
import textwrap
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.ddl import CreateTable
@compiles(CreateTable, "postgresql")
def pg10_partition_compiler(element, compiler, **kw):
"""
Simple helper that enables Postgresql 10's declarative partitioning features.
partition_by : str = Plain sql string that defines partition rules for the parent table.
import json
import os
import urllib.request
def format_message(data):
severity_level = get_severity_level(data['detail']['severity'])
payload = {
'username': 'GuardDuty Finding',
'icon_emoji': ':guardduty:',
'text': '{} GuardDuty Finding in {}'.format(severity_level['mention'], data['detail']['region']),
@pachadotdev
pachadotdev / 00-install-intel-mkl-64bit
Last active February 4, 2021 07:59
Install Intel MKL (64 bit) on Ubuntu 17.10
# Option 1: Use apt-get
# keys taken from https://software.intel.com/en-us/articles/installing-intel-free-libs-and-python-apt-repo
cd ~/GitHub/r-with-intel-mkl/
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
sudo apt-get update && sudo apt-get install intel-mkl-64bit
@kkweon
kkweon / DQN_PyTorch.py
Created June 8, 2017 22:18
PyTorch DQN implementation
"""
DQN in PyTorch
"""
import argparse
import torch
import torch.nn
import numpy as np
import random
import gym
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
@spro
spro / pytorch-simple-rnn.py
Last active November 7, 2024 11:24
PyTorch RNN training example
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.autograd import Variable
from torch import optim
import numpy as np
import math, random
# Generating a noisy multi-sin wave
function proxyMethods(proxyObj, originalObj, props) {
props.forEach(function(method) {
proxyObj[method] = function() {
return originalObj[method](...arguments);
};
});
}
function proxyProps(proxyObj, originalObj, props) {
props.forEach(function(prop) {
@veselosky
veselosky / s3gzip.py
Last active August 29, 2024 11:32
How to store and retrieve gzip-compressed objects in AWS S3
# vim: set fileencoding=utf-8 :
#
# How to store and retrieve gzip-compressed objects in AWS S3
###########################################################################
#
# Copyright 2015 Vince Veselosky and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@jdp
jdp / searchindex.py
Created November 25, 2012 00:06
Autocomplete search with Redis and Python
from functools import partial
from itertools import imap, izip, product
from redis import Redis
class SearchIndex(object):
"""Autocomplete search index.
>>> index = SearchIndex(Redis())
@mrflip
mrflip / gist:766608
Created January 5, 2011 17:15
Elasticsearch shell config
We couldn’t find that file to show.