Skip to content

Instantly share code, notes, and snippets.

View playerjamesbattleground's full-sized avatar

james jiang playerjamesbattleground

View GitHub Profile
@playerjamesbattleground
playerjamesbattleground / gist:566fa6c55a3870ad8e3db5e90d9666b0
Created May 26, 2022 23:56 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@playerjamesbattleground
playerjamesbattleground / SftpServiceTest.java
Created June 2, 2016 02:44 — forked from ToastShaman/SftpServiceTest.java
Using an embedded Apache MINA SSHD server in a unit test to verify that your code is able to upload a file through SFTP. This unit tests uses JSch as the client to speak to an embedded Apache MINA sftp server and verifies that the upload of a text file was successful.
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb
@playerjamesbattleground
playerjamesbattleground / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- access -->
<property name="driverClass" value="${db.driverclass}" />
<property name="jdbcUrl" value="${db.url}" />
<property name="user" value="${db.user}" />
<property name="password" value="${db.password}" />
<!-- pool sizing -->
<property name="initialPoolSize" value="3" />
<property name="minPoolSize" value="6" />
<property name="maxPoolSize" value="25" />
function readDir(start, callback) {
// Use lstat to resolve symlink if we are passed a symlink
fs.lstat(start, function(err, stat) {
if(err) {
return callback(err);
}
var found = {dirs: [], files: []},
total = 0,
processed = 0;
function isDir(abspath) {
#!/bin/bash
# The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
# Make sure we are on CentOS
OS=`cat /etc/redhat-release | awk {'print $1}'`

A demo of the d3.geo.tile plugin, which determines which 256x256 tiles are visible in the viewport based on a scale and translate. This demo combines the tile plugin with d3.behavior.zoom for panning and zooming, resulting in a a simple slippy map. Based partly on an example by Tom MacWright.

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gordondickens.sample</groupId>
<artifactId>sample-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>