Skip to content

Instantly share code, notes, and snippets.

View isaku-dev's full-sized avatar

isaku.dev isaku-dev

View GitHub Profile
@isaku-dev
isaku-dev / .ebextensions\deploy.config
Created December 7, 2017 13:14 — forked from pdib/.ebextensions\deploy.config
Installing node and npm on a Django AWS ElasticBeanstalk
# This specifies the deployment process on AWS ElasticBeanstalk for a Django app using npm and Postgres.
#
# The target environment should have access to a Postgres Database through environment variables.
# The environment can be setup using `eb create --database.engine=postgres`
# The necessary environment variables to access the database will be automatically defined on the
# instances of that environment.
#
# In addition, the target environment should define environment variables (django secret key ...).
# They can be manually defined using the AWS ElasticBeanstalk interface on the web.
# They can also be specified when creating the environment from command line, for example:
@isaku-dev
isaku-dev / secret-key-gen.py
Created December 6, 2017 15:37 — forked from ndarville/secret-key-gen.py
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@isaku-dev
isaku-dev / zfs-arc-statsd.sh
Created November 24, 2017 11:29 — forked from dlanderson/zfs-arc-statsd.sh
Send ZFS Linux metrics to statsd
#!/bin/bash
# A port of ZFS stats for FreeBSD plugin to Linux, adapted to send metrics to statsd.
#
# Author: Daniele Valeriani <daniele@valeriani.co.uk>
# Author of the original munin plugin: David Bjornsson <dabb@lolnet.is>
# Author of the Linux port: Alex Chistyakov <alexclear@gmail.com>
PREFIX="servers.`hostname`.zfs"
STATSD_ADDR="YOUR STATSD SERVER"
@isaku-dev
isaku-dev / customize_wsgi.config
Created November 22, 2017 10:52 — forked from djshen-ponddy/customize_wsgi.config
Customize AWS Elastic Beanstalk wsgi.conf without being wiped out after update of environment variables
files:
"/opt/elasticbeanstalk/hooks/configdeploy/pre/99patchwsgi.py": &file
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env python
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
@isaku-dev
isaku-dev / fabfile.py
Created November 16, 2017 09:51 — forked from pix0r/fabfile.py
Sample Fabric environment setup
from fabric.api import env, run
from fabric.contrib.project import rsync_project
try:
from fabfile_local import *
except ImportError, e:
environments = {
"dev": {
"hosts": ["localhost"],
},
@isaku-dev
isaku-dev / s3api.sh
Created November 8, 2017 11:23 — forked from phlipper/s3api.sh
AWS CLI S3 Update ACLs
aws s3api list-objects --bucket=mys3bucket \
--region=us-west-2 \
--output=text \
--prefix=myprefix \
--query='Contents[].[Key]' | \
xargs -P4 -I % aws s3api put-object-acl \
--acl=public-read \
--region=us-west-2 \
--bucket=mys3bucket \
--key='%'
@isaku-dev
isaku-dev / s3update.py
Created November 7, 2017 11:05 — forked from nateware/s3update.py
Check local files vs what's on S3, and upload any that have changed.
#!/usr/bin/env python
# Compare a file on S3 to see if we have the latest version
# If not, upload it and invalidate CloudFront
import fnmatch
import os
import boto
import pprint
import re
@isaku-dev
isaku-dev / xor_keras.py
Created September 15, 2017 13:47 — forked from ricgu8086/xor_keras.py
Comparing XOR between tensorflow and keras
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
from keras.optimizers import SGD
X = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
y = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(2, input_dim=2, activation='sigmoid'))
@isaku-dev
isaku-dev / .ps1
Created May 9, 2017 09:34
IIS Log Cycle Events
Import-Module WebAdministration
Set-WebConfigurationProperty '/system.applicationHost/applicationPools/applicationPoolDefaults/recycling' -Name logEventOnRecycle -value &quot;Time, Requests, Schedule, Memory, IsapiUnhealthy, OnDemand, ConfigChange, PrivateMemory&quot;
$pools = Get-ChildItem iis:\apppools
foreach ($pool in $pools){
$poolname = $pool.Name
Set-ItemProperty iis:\apppools\$poolname -name recycling -value @{logEventOnRecycle=&quot;Time, Requests, Schedule, Memory, IsapiUnhealthy, OnDemand, ConfigChange, PrivateMemory&quot;}
}
@isaku-dev
isaku-dev / .sql
Created May 5, 2017 13:21
Oracle PL SQL String Split
with test_1 as
(
select regexp_replace('ab mori sherbim konf modemit te riab ka sherbim u verifikua.____________________.Problem Description.11.01.2016 15:06:53 U07996..abonenti nuk ka sherbim.____________________.Problem Description.11.01.2016 09:56:38 SERVICEDESK..ab mori sherbim konf modemit te ri.____________________.Problem Description.10.01.2016 10:01:24 U09148..ab ska sherbim ne ne internet' ,'(._+.Problem Description.)','|') replaced_str
from dual
)
select regexp_substr(replaced_str,'[^|]+',1,level)
from test_1
connect by level <= length( regexp_substr(replaced_str,'[^|]+',1)) + 1