Skip to content

Instantly share code, notes, and snippets.

@elleryq
elleryq / o2i.java
Created March 23, 2015 09:46
Object array to Integer array
public class o2i {
private static Object getIntArray()
{
int[] array = new int[] { 1, 2, 3, 4, 5};
Object obj = array;
return obj;
}
public static void main(String[] args) {
Object obj = getIntArray();
@elleryq
elleryq / Ping.py
Created March 23, 2015 09:44
Ping in Python
import sys
import socket
if len(sys.argv) < 2:
print("Need at least 1 parameters.")
print("Usage: {0} host".format(sys.argv[0]))
sys.exit(-1)
r = False
try:
@elleryq
elleryq / Ping.java
Created March 23, 2015 09:43
Ping via InetAddress.isReachable().
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.IOException;
class Ping {
public static void main(String[] args) {
InetAddress in;
try {
in = InetAddress.getByName(args[0]);
## {{{ http://code.activestate.com/recipes/576646/ (r4)
# -*- coding: utf-8 -*-
'''
rename_to_exiftime.py
Rename JPEG files according to EXIF-date using PIL
If global variable CREATE_HARDLINK is set, script creates Windows (XP) batch file
for creating hardlink version of source files
@elleryq
elleryq / helloworld__init__.py
Created March 19, 2015 09:49
Calibre Plugin - HelloWorld
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <[email protected]>'
__docformat__ = 'restructuredtext en'
import os
@elleryq
elleryq / guess.cs
Created March 19, 2015 09:36
猜數字遊戲
using System;
using System.Linq;
public class Guess
{
public static void Main(string[] args)
{
int scoreCount = 0, score = 100;
string answer = "test", user_input, out_put = string.Empty;
Console.WriteLine("Enter a length {0} word start with {1}:", answer.Length.ToString(), answer.Substring(0, 1));
do
@elleryq
elleryq / guess.py
Last active August 29, 2015 14:17
猜數字遊戲
def main():
answer = "test"
user_input = ""
score = 100
count = 0
while user_input!=answer:
user_input = raw_input("Enter a length 4 word start with t:")
if len(user_input)<len(answer):
print("Wrong input, input again.")
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@elleryq
elleryq / entity.java
Created March 12, 2015 10:04
SugarORM 1..n example
public class Book extends SugarRecord<Book> {
String name;
String ISBN;
int bookshelf; // key to get bookshelf
}
public class BookShelf extends SugarRecord<BookShelf> {
String location;
public List<Book> getBooks() {
#! /bin/bash
#
# backup_redmine.sh
# modified by [email protected]
# Inspiration: https://gist.github.com/gabrielkfr/6432185
#
# Distributed under terms of the MIT license.
# -- VARS
DAY=`date +"%Y%m%d"`