This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Random Int | |
SELECT FLOOR(RAND() * 100); | |
-- Random float | |
select FLOOR(RAND() * 1000 ) + round(rand() * 0.49 + 0.01, 2); | |
-- Random Srting | |
SELECT MD5(RAND()); | |
SELECT TO_BASE64(UNHEX(HEX(MD5(RAND())))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.util.Scanner; | |
public class PlusZerro { | |
// Размер игровово поля | |
private static final byte bPoleSize = 3; | |
// Задаем поле как (!)одномерный массив bPoleSize*bPoleSize (неожиданно?) | |
private static String[] pole = new String[bPoleSize * bPoleSize]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calc; | |
import java.io.*; | |
import java.util.*; | |
public class Calc { | |
public static void main(String[] args) throws Exception { | |
BufferedReader d = new BufferedReader(new InputStreamReader(System.in)); | |
String sIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mysqli = new mysqli('localhost', '#username', '#password', '#database'); | |
$handle = fopen('sqldump.sql', 'rb'); | |
if ($handle) { | |
while (!feof($handle)) { | |
// This assumes you don't have a row that is > 1MB (1000000) | |
// which is unlikely given the size of your DB | |
// Note that it has a DIRECT effect on your scripts memory | |
// usage. | |
$buffer = stream_get_line($handle, 1000000, ";\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Possible values for ext-name: | |
bcmath | |
bz2 | |
calendar | |
ctype | |
curl | |
dba | |
dom | |
enchant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$regex = '/^(?P<IP>\S+) | |
\ (?P<ident>\S) | |
\ (?P<auth_user>.*?) # Spaces are allowed here, can be empty. | |
\ (?P<date>\[[^]]+\]) | |
\ "(?P<http_start_line>.+ .+)" # At least one space: HTTP 0.9 | |
\ (?P<status_code>[0-9]+) # Status code is _always_ an integer | |
\ (?P<response_size>(?:[0-9]+|-)) # Response size can be - | |
\ "(?P<referrer>.*)" # Referrer can contains everything: its just a header | |
\ "(?P<user_agent>.*)"$/xU'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl genrsa -out CAroot.key 2048 | |
openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below | |
openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt | |
cat CAroot.crt CAroot.key > CAroot.pem | |
openssl genrsa -out mongod.key 2048 | |
openssl req -new -key mongod.key -out mongod.csr | |
openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt | |
cat mongod.crt mongod.key > mongod.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update IPs on Mac | |
Create a file com.ips.docker_127005_alias.plist | |
com.ips.docker_127005_alias.plist | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can ask zsh to only display targets tag for the make command completion with | |
zstyle ':completion:*:*:make:*' tag-order 'targets' | |
Add above code somewhere after the line | |
autoload -U compinit && compinit |
NewerOlder