Skip to content

Instantly share code, notes, and snippets.

@eldargab
eldargab / docker-compose.yml
Created October 13, 2022 14:16 — forked from isSerge/docker-compose.yml
Subsquid Archive docker-compose.yml
services:
db:
image: postgres:12 # CockroachDB cluster might be a better fit for production deployment
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: squid-archive
ingest:
Attaching to subsquid-subspace_ingest_1, subsquid-subspace_gateway_1, subsquid-subspace_explorer_1, subsquid-subspace_db_1
db_1 | The files belonging to this database system will be owned by user "postgres".
db_1 | This user must also own the server process.
db_1 |
db_1 | The database cluster will be initialized with locale "en_US.utf8".
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
db_1 |
db_1 | Data page checksums are disabled.
db_1 |
@eldargab
eldargab / no_crush_dialog.reg
Created June 1, 2017 08:21
Prevent dialog appearance on app crush
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting]
"ForceQueue"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent]
"DefaultConsent"=dword:00000001
@eldargab
eldargab / FastScanner.java
Created March 28, 2017 15:52
Scanner for programming contests
public class FastScanner implements Iterator<String>, Iterable<String>, Closeable {
private Reader reader;
private StringBuilder sb = new StringBuilder();
private char[] buf = new char[4096];
private char current;
private int beg = 0;
private int end = 0;
public FastScanner(Reader reader) {
this.reader = reader;
@eldargab
eldargab / Jaxb.java
Created February 6, 2017 11:40
Simpler thread-safe jaxb marshalling - unmarshalling
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.Callable;
/**
@eldargab
eldargab / Args.java
Last active September 21, 2017 14:27
A small wrapper around args4j
import org.kohsuke.args4j.ClassParser;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.PrintStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@eldargab
eldargab / TSQL-Locks.sql
Created December 23, 2015 15:04
Figure out MSSQL lock state
--============================================
--View Locking in Current Database
--Author: Timothy Ford
--http://thesqlagentman.com
--============================================
SELECT DTL.resource_type,
CASE
WHEN DTL.resource_type IN ('DATABASE', 'FILE', 'METADATA') THEN DTL.resource_type
WHEN DTL.resource_type = 'OBJECT' THEN OBJECT_NAME(DTL.resource_associated_entity_id, SP.[dbid])
WHEN DTL.resource_type IN ('KEY', 'PAGE', 'RID') THEN
@eldargab
eldargab / fk_relations.sql
Created November 25, 2015 13:26
Find out foreign key relations in MS SQL database
-- credits - http://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server
SELECT obj.name AS FK_NAME,
sch.name AS [schema_name],
tab1.name AS [table],
col1.name AS [column],
tab2.name AS [referenced_table],
col2.name AS [referenced_column]
FROM sys.foreign_key_columns fkc
INNER JOIN sys.objects obj
ON obj.object_id = fkc.constraint_object_id
@eldargab
eldargab / bench.js
Last active December 15, 2015 19:19
string startsWith() benchmark
var Suite = require('benchmark').Suite
function startsWith(prefix, str) {
for (var i = 0; i < prefix.length; i++) {
if (prefix[i] != str[i]) return false
}
return true
}
var suite = new Suite
var Flow = require('make-flow')
var crypto = require('crypto')
function Hash (str) {
var salt = '%9023t89gisuhslKLJifsdjl;apasfk<klas,Q%G@0jq39'
return crypto.createHash('sha256').update(salt + str).digest('hex')
}
var login = Flow()
.def('users', function (done) {