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 img | |
import ( | |
"database/sql" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
"io" | |
"log" | |
"net/http" | |
"os" |
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 com.utils; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.InputStream; | |
/*** | |
* | |
* @ClassName CopyUtils |
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
var ISBN = (function(){ | |
"use strict"; | |
var validateISBN13 = function(isbnChars){ | |
var checksum = 0; | |
isbnChars.forEach(function(isbnChar, key){ | |
checksum += parseInt(isbnChar, 10) * (key % 2 === 1 ? 3 : 1); | |
}); |
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
<?php | |
$a = [ 'Date','Media','Geo' ]; | |
$b = [ 'Num' ]; | |
$subject = [ 'Date'=>'2019-04-26','Media'=>'AAA','Geo'=>'CN','Num'=>105 ]; | |
// 多维数组的最后一项 | |
$value = array_intersect_key($subject, array_fill_keys($b, 1)); | |
// 生成多维数组 | |
$res = createMultiArray($a, $value, $subject); | |
var_dump([ |
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
be sure u have a .gitignore in your home-folder | |
cd/<REPOSITORY> | |
find . -type l | sed -e s'/^\.\///g' >> ~/.gitignore |
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
/** | |
* 使用 snowflake 算法生成递增的分布式唯一ID. | |
* 该算法支持 15 条业务线,4 个数据中心,每个数据中心最多 128 台机器,每台机器每毫秒可生成 4096 个不重复ID. | |
*/ | |
class Snowflake | |
{ | |
const SEQUENCE_BITS = 12; | |
const MILLISECOND_BITS = 39; | |
const BUSINESS_ID_BITS = 4; | |
const DATA_CENTER_ID_BITS = 2; |
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
/* Chrome DOM i18n: Easy i18n for your Chrome extensions and apps' DOM. | |
* 2011-06-22 | |
* | |
* By Eli Grey, http://eligrey.com | |
* Public Domain. | |
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. | |
*/ | |
/*jslint laxbreak: true, strict: true*/ | |
/*global self, chrome, document*/ |
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
#! /bin/bash | |
# | |
# to restore: | |
# gunzip XXX.db.gz | |
# dokku postgres:import <dbname> < XXX.db | |
# directory to save backups in, must be rwx by postgres user | |
BASE_DIR="/var/backups/postgres" | |
YMD=$(date "+%Y-%m-%d") | |
DIR="$BASE_DIR" |
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
// ecdh implements a simple way to perform Diffie-Hellman Key Exchange using | |
// Curve25519 on the command line. | |
// | |
// NOTE: this is a toy for fun. Don't use it. | |
// | |
// See https://godoc.org/golang.org/x/crypto/curve25519 and | |
// https://cr.yp.to/ecdh.html for more info. | |
// | |
// The final shared secret given is the raw shared secret bytes from DH and is | |
// not typically suitable for direct use as an encryption key as it can leak |
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
- (NSAttributedString *)textAligenJustifiedWith:(NSString *)text lineSpace:(CGFloat)lineSpace { | |
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:text]; | |
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; | |
paragraphStyle.alignment = NSTextAlignmentJustified; | |
paragraphStyle.paragraphSpacing = 11.0; | |
paragraphStyle.paragraphSpacingBefore = 10.0; | |
paragraphStyle.firstLineHeadIndent = 0.0; |
OlderNewer