Skip to content

Instantly share code, notes, and snippets.

View fujohnwang's full-sized avatar
🌓
儒释道法自然

王福强 fujohnwang

🌓
儒释道法自然
View GitHub Profile
@ssokolow
ssokolow / pagination_example.sql
Created December 23, 2009 13:02
Reasonably efficient pagination without OFFSET (SQLite version)
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@retronym
retronym / drop-to-repl-2.8.scala
Created January 30, 2010 17:12
Embedding REPL in 2.8 working around classpath propagation changes.
object IntepreterFix {
import scala.tools.nsc._
import Interpreter._
def break(args: DebugParam[_]*): Unit = {
val intLoop = new InterpreterLoop
intLoop.settings = {
val s = new Settings(Console.println)
// need to pass this explicitly to the settings for Scalac.
// See: http://old.nabble.com/-scala--recent-changes-in-2.8-nightly-classpath-management-td26233977.html
@chuangbo
chuangbo / README.md
Last active June 19, 2023 04:48
Python dynamic DNSPod DNS Script

替换上你的 API Token,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获取 API Token 的方式

获得 domain_id 可以用 curl

curl -k https://dnsapi.cn/Domain.List -d "login_token=TOKEN"`
@retronym
retronym / sbt-dynamic-scalac-options.scala
Created June 26, 2011 14:49
SBT 0.10 dynamic scalac options
object StandardBuild {
lazy val standardSettings: Seq[Project.Setting[_]] =
Defaults.defaultSettings ++ compilerSettings
lazy val scalacBaseOptions = SettingKey[Seq[String]]("scalac-base-options", "Options for the Scala Compiler in all modes")
lazy val scalacSnapshotOptions = SettingKey[Seq[String]]("scalac-snapshot-options", "Options for the Scala Compiler in Development Mode")
lazy val scalacReleaseOptions = SettingKey[Seq[String]]("scalac-release-options", "Options for the Scala Compiler in Release Build")
lazy val compilerSettings: Seq[Project.Setting[_]] = Seq(
scalacSnapshotOptions := Seq("-Xcheckinit"),
autoCompilerPlugins := true
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.1")
scalacOptions += "-P:continuations:enable"
@toutantic
toutantic / JgitTest
Created November 9, 2011 09:51
Code sample for jgit
package net.toutantic.jgit;
import static org.junit.Assert.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
@khotyn
khotyn / GarbageCollectors.java
Created December 26, 2011 11:26
Garbage collectors used in HotSpot JVM under different VM Options
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
/**
* Print the Collector used in the program.
* @author khotyn
@rednaxelafx
rednaxelafx / DirectMemorySize.java
Created January 11, 2012 07:18
An Serviceability-Agent based tool to see stats of NIO direct memory, as an alternative on JDK6 without JMX support for direct memory monitoring. Only works on JDK6; to work on JDK7 will need some tweaking because static variables are moved to Java mirror
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
import sun.jvm.hotspot.utilities.*;
public class DirectMemorySize extends Tool {
@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@jewelsea
jewelsea / PopupExample.java
Created February 27, 2012 18:50
JavaFX Popup example
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Popup;
import javafx.stage.Stage;