Skip to content

Instantly share code, notes, and snippets.

View non7top's full-sized avatar

non7top non7top

  • Bakı
  • 04:16 (UTC +04:00)
View GitHub Profile
@non7top
non7top / sysctl.conf
Last active September 14, 2015 07:48 — forked from kfox/sysctl.conf
Linux kernel tuning settings for large number of concurrent clients
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
@non7top
non7top / in a flask
Created May 12, 2016 09:09 — forked from oxpa/in a flask
range getting files from server
def generate(taskname, ext='html'):
#jobs=get_results_from_redis()
#job = [i for i in jobs if i.name == taskname][0]
try:
logfile = open('/opt/deploy/var/log/tasks/%s.%s'%(taskname, ext), 'r')
except:
raise StopIteration
yield ''.join(logfile.readlines())
#while job.status != 'SUCCESS' and job.status != 'FAIL' and job.status != 'STOP' and logfile:
@non7top
non7top / skeleton-daemon.sh
Created July 6, 2016 12:40 — forked from shawnrice/skeleton-daemon.sh
A template to write a quick daemon as a bash script
#!/bin/sh
# This is a skeleton of a bash daemon. To use for yourself, just set the
# daemonName variable and then enter in the commands to run in the doCommands
# function. Modify the variables just below to fit your preference.
daemonName="DAEMON-NAME"
pidDir="."
pidFile="$pidDir/$daemonName.pid"
@non7top
non7top / sniff.txt
Created September 17, 2016 15:25 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n
@non7top
non7top / custom-error-page
Created January 25, 2017 14:06 — forked from simlegate/custom-error-page
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
@non7top
non7top / pre-commit
Created September 14, 2017 21:43 — forked from jamtur01/pre-commit
A Terraform validation and formatting pre-commit hook
#!/usr/bin/env bash
set -e
# Formats any *.tf files according to the hashicorp convention
files=$(git diff --cached --name-only)
for f in $files
do
if [ -e "$f" ] && [[ $f == *.tf ]]; then
#terraform validate `dirname $f`
terraform fmt $f
@non7top
non7top / assume-role-policy.json
Created September 20, 2017 09:47 — forked from clstokes/assume-role-policy.json
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@non7top
non7top / WinRM-Insecure-Bootstrap.ps1
Created December 12, 2017 17:32 — forked from thomasalley/WinRM-Insecure-Bootstrap.ps1
Quickly bootstrap a Windows host to allow insecure connections. Also creates an HTTPS listener with a self-signed cert.
winrm quickconfig -q -force
Enable-psremoting –force
Set-executionpolicy bypass –force
winrm set winrm/config/service/Auth '@{Basic="true"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'
winrm set winrm/config/client '@{TrustedHosts="*"}'
# Configuration Warning:
# install 7-zip, curl and vim
# (Windows 2012 comes with .NET 4.5 out-of-the-box)
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2012 64bits AMIs provided by Amazon (eu-west-1 ami-a1867dd6)
#
# Inject this as user-data of a Windows 2012 AMI, like this (edit the adminPassword to your needs):
#
# <powershell>
# Set-ExecutionPolicy Unrestricted
@non7top
non7top / nginx-lua-s3.nginxconf
Created January 14, 2018 21:51 — forked from raucao/nginx-lua-s3.nginxconf
Nginx proxy to S3
location ~* ^/s3/(.*) {
set $bucket '<REPLACE WITH YOUR S3 BUCKET NAME>';
set $aws_access '<REPLACE WITH YOUR AWS ACCESS KEY>';
set $aws_secret '<REPLACE WITH YOUR AWS SECRET KEY>';
set $url_full "$1";
set_by_lua $now "return ngx.cookie_time(ngx.time())";
set $string_to_sign "$request_method\n\n\n\nx-amz-date:${now}\n/$bucket/$url_full";
set_hmac_sha1 $aws_signature $aws_secret $string_to_sign;
set_encode_base64 $aws_signature $aws_signature;