Skip to content

Instantly share code, notes, and snippets.

View aidoskz's full-sized avatar

Aidos aidoskz

  • Kazakhstan, Astana
View GitHub Profile
import os
import sys
import importlib.abc
import importlib.util
import json
import yaml
ex_registry = []
@jclausen
jclausen / haproxy.cfg
Created March 5, 2017 23:04
Haproxy - Load Balance All Domains with SSL Termination
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 1024
@axic
axic / stringaskey.sol
Last active July 10, 2019 00:10
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
@ggrandes
ggrandes / openssl-smime.sh
Last active September 6, 2024 22:33
OpenSSL S/MIME 3.1 (CMS) - Encrypt/Signature - Verify/Decrypt
# Original Source:
# https://gist.github.com/ggrandes/a57c401f1bad6bd0ffd87a557b7b5790
# SIGN / VERIFY
openssl cms -sign -keyid -md sha256 -nodetach -binary -in /etc/passwd -signer user.crt -inkey user.key -out x.smime -outform SMIME
openssl cms -verify -CAfile ca.crt -in x.smime -inform SMIME
# ENCRYPT / DECRYPT
openssl cms -encrypt -keyid -aes-256-cbc -in /etc/passwd -binary -out x.smime -outform SMIME user.crt
openssl cms -decrypt -in x.smime -inform SMIME -recip user.crt -inkey user.key
@ambroisemaupate
ambroisemaupate / security.conf
Last active December 10, 2025 14:11
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@aidoskz
aidoskz / converter.js
Created January 23, 2015 04:35
from FORM to JSON
JSON.parse(('{"' + $('form').serialize() + '"}').replace(/=+/gi,'":"').replace(/&+/gi,'","'));
@aidoskz
aidoskz / Util.list.pagination
Created November 13, 2014 03:31
Pagination of list table from Oracle SQL
public List<T> getList(long first, long last, String selectSql) throws SQLException {
List<T> list = new ArrayList<T>();
String query = "select * from (select rownum rn,sq1.* from " +
"("+selectSql+") sq1)" +
" sq2 where sq2.rn>=" + first + " and sq2.rn<=" + last;
Statement stmt = this.conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
list.add(convert(conn, rs));
rs.close();
select * from
( select a.*, ROWNUM rnum from
( <your_query_goes_here, with order by> ) a
where ROWNUM <= :MAX_ROW_TO_FETCH )
where rnum >= :MIN_ROW_TO_FETCH;
@foozmeat
foozmeat / openssl-build.sh
Last active May 22, 2024 17:56
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
<?php
/**
* Oracleページ制御用SQL生成クラス
*
* Oracle8以降(?たぶん)でPostgreSQL、MySQLでいうLIMIT、OFFSETを利用するためのPHP4用クラス。
* データベースに実際にアクセスするのではなくSQLを返す。
* このクラスの関数はOraclePagination::PageCount()のようにstaticに利用する。
* 1ページ分のレコードだけを抽出するSQL文、行数ではなく何ページあるかを返すSQLを生成する。
*
* $page_numberに指定したページの行を選択する。$lines_per_pageには1ページあたりの行数を指定。