Skip to content

Instantly share code, notes, and snippets.

@ywjno
ywjno / REAME.md
Created October 15, 2013 09:33 — forked from romansklenar/REAME.md

How to set up your VPS with Chef Solo

1. What is it?

There are many different provisioning tools out there, the most popular of which are Chef and Puppet. Chef uses Ruby, Puppet uses a DSL (Domain Specific Language), there are others that use simple bash too, but today we're going to focus on Chef Solo.

2. Dependencies

To get Chef working properly on your local machine you need a few things.

Make sure you use Ruby 1.9.x and not Ruby 2.x as you will get errors with the json 1.6.1 gem on 2.x. Use rbenv or RVM to manage several different Rubies on the one machine.

@ywjno
ywjno / connection.rb
Last active December 29, 2015 04:09
Net::HTTP Example
# encoding: utf-8
require "net/http"
require "uri"
class Connection
VERB_MAP = {
:get => Net::HTTP::Get,
:post => Net::HTTP::Post,
:put => Net::HTTP::Put,
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>Float Label Pattern</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style type="text/css" media="screen">
.row {
/*position: relative;*/
padding-top: 24px;
@ywjno
ywjno / build_jar.rb
Created June 17, 2014 04:09
build_jar
# encoding: utf-8
require "json"
require "fileutils"
conf = JSON.load(File.open(File.expand_path("../conf.json", __FILE__), 'r'))
tmp_path = conf['tmp_path'] || File.expand_path("../tmp", __FILE__)
FileUtils.rm_rf(tmp_path) if File.exist?(tmp_path)
@ywjno
ywjno / gist:777c1af1f8ef0a38a931
Created August 10, 2014 09:17
'_PC_64' undeclared (first use in this function)
add this code
```c
#ifndef _PC_64
#define _PC_64 0x00000000
#endif
#ifndef _MCW_PC
#define _MCW_PC 0x00030000
#endif
@ywjno
ywjno / truck_location.c
Created September 24, 2014 15:30
coursera_[Computer Programming]_homework2
#include <stdio.h>
#define SPEED 10
// 北:0,东:1,南:2,西:3
int path = 0;
int x = 0;
int y = 0;
int getDistance(int time) {
@ywjno
ywjno / RemoteSQLite.cs
Last active August 29, 2015 14:08
RemoteSQLite.cs
using System;
using System.Data;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
/*
@ywjno
ywjno / JSTORsearch.py
Last active August 29, 2015 14:08
JSTOR search
#!/usr/bin/python
import os, sys
metaPath = './PRE_1923_METADATA'
#Returns a list of all metafiles in './PRE_1923_METADATA'
def fileList(path):
files = []
for root, dirs, allFiles in os.walk(path):
@ywjno
ywjno / Sizeof.java
Created January 27, 2015 05:37
判断某个java对象占用内存情况
public class Sizeof {
public static void main(String[] args) throws Exception {
// "warm up" all classes/methods that we are going to use:
runGC();
usedMemory();
// array to keep strong references to allocated objects:
final int count = 10000; // 10000 or so is enough for small ojects
Object[] objects = new Object[count];
@ywjno
ywjno / EmojiFilter.java
Created January 27, 2015 07:57
EmojiFilter.java
import org.apache.commons.lang.StringUtils;
public class EmojiFilter {
/**
* 检测是否有emoji字符
* @param source
* @return 一旦含有就抛出
*/
public boolean containsEmoji(String source) {
if (StringUtils.isBlank(source)) {