Skip to content

Instantly share code, notes, and snippets.

View strongant's full-sized avatar

strongant strongant

View GitHub Profile
@doubledouble
doubledouble / jvm内存模型
Created June 29, 2012 04:21
jvm内存模型
jvm内存模型
---JMM就是java解决多线程下内存共享的一个模型,与内存分区管理是不同的层面!
根据线程私有和线程共享来看:
线程私有:
---程序计数器:如果正在执行Java方法,则指向虚拟机字节码指令的地址,如果是native的,这个计算器的值为空。
---虚拟机栈:保存本地变量、操作数栈、动态链接、方法出口等信息。为执行java方法服务。
@ivanarrizabalaga
ivanarrizabalaga / groovy+regexp+curlybrackerts
Last active March 17, 2018 19:12
Groovy regexp capturing content inside curly brackets
import java.util.regex.Matcher
import java.util.regex.Pattern
//Tring to capture whats inside the curly brackets
String input="xxx{var23.ID}yyy{something here.some more}--{}"
//The group is everything but a '}'
def pattern = ~/\{([^\}]*)\}/
def result=pattern.matcher(input)
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 4, 2024 04:16
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@yusuiked
yusuiked / ConcurrentNew.java
Last active October 16, 2020 16:07
Sample code to sort by word length.
import java.util.concurrent.atomic.LongAdder;
public class ConcurrentNew {
public static void main(String[] args) {
// Java8 から追加された、複数スレッドからアトミックに更新できる Long 型の LongAdder
// Java5 からある、AtomicInteger などと同じような考え方だが、Atomic系のクラスよりも高いパフォーマンスを出す。
// 複数スレッドから頻繁に更新するようなケースで高いパフォーマンスを発揮する。
// 他にも DoubleAdder などがある。
LongAdder longAdder = new LongAdder();
// 加算
@subchen
subchen / jetbrick.print.js
Created November 3, 2014 10:30
JavaScript 实现打印功能(只打印网页中的一部分)
(function(window, $) {
/**
* 实现打印功能(只打印网页中的一部分)
*
* Usage:
* <button jw-click-print="#printContext">Print</button>
*/
var print = function($dom) {
$("iframe.js-print").remove();
@tpai
tpai / instructions.md
Last active September 22, 2022 11:20
use both Tor and Privoxy with Mac OSX

1. install

brew install tor
brew install privoxy

2. copy and modify config file

@tychobrailleur
tychobrailleur / 01 Bootstrap.md
Last active January 16, 2018 10:06
Grails Notes

Bootstrap Scripts

## Grails script, startGrails Grails main class in startGrails is org.codehaus.groovy.grails.cli.support.GrailsStarter that sets up config to execute org.codehaus.groovy.grails.cli.GrailsScriptRunner to run Groovy scripts. Executes the Groovy script, in interactive mode if no script invoked. ~/.grails/.aliases may contain command aliases.

Startup

RunApp.groovy -> _GrailsRun.groovy instantiates GrailsProjectRunner (org.codehaus.groovy.grails.project.container.GrailsProjectRunner in grails-project-api). Also calls _GrailsWar that calls _GrailsClean and _GrailsPackage.

_GrailsPackage.groovy packageApp calls:

  • compile from _GrailsCompile.groovy that compiles Groovy and Java sources (“Packaging Grails application”).
@rherrmann
rherrmann / CloneLearningTest.java
Last active July 21, 2023 19:15
'Learning Tests' that uses the JGit API to clone existing repositories: http://www.codeaffine.com/2015/11/30/jgit-clone-repository/
package com.codeaffine.jgit.example;
import static java.util.Collections.singleton;
import static org.eclipse.jgit.api.ListBranchCommand.ListMode.ALL;
import static org.eclipse.jgit.transport.RemoteConfig.getAllRemoteConfigs;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.util.List;
@yzyzsun
yzyzsun / shadowsocks-libev.sh
Last active August 16, 2023 05:38
shadowsocks-libev server setup script on CentOS 7
cd /etc/yum.repos.d
curl -O https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-7/librehat-shadowsocks-epel-7.repo
yum -y install shadowsocks-libev
setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/ss-server
cat > /etc/shadowsocks-libev/config.json << 'EOF'
{
"server": "0.0.0.0",
"server_port": 443,
"password": "p@$$w0rd",
"method": "aes-128-gcm"
@atrolla
atrolla / howto.md
Last active October 31, 2022 15:52
Deploy multiple Spring boot app on a single tomcat with different configuration for each app