Skip to content

Instantly share code, notes, and snippets.

View Feuda's full-sized avatar
👋
Hi

Feuda Nan Feuda

👋
Hi
View GitHub Profile
@Feuda
Feuda / gist:f139a2a2d5e388ba3e77
Created October 20, 2014 08:35
Heroku get origin data in local database
PGUSER=PG_USERNAME PGPASSWORD=PG_PASSWORD heroku pg:pull HEROKU_POSTGRESQL_GRAY_URL DB_NAME --app APP_NAME

Setup Rails application production environment on Ubuntu

Add deploy user

ssh root@YOURDOMAIN
adduser deploy
visudo # Add deploy ALL=(ALL) ALL

Install necessary libraries

@Feuda
Feuda / gist:2156929
Created March 22, 2012 07:56
ie and ff
<html>
<body>
<input type="text" id="txt" value="ddd"/>
<SCRIPT LANGUAGE="JavaScript">
<!--
var v = document.all.txt.value;
alert(v);
//-->
</SCRIPT>
</body>
@Feuda
Feuda / gist:2156925
Created March 22, 2012 07:55
ie or ff
<html>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
if(document.all)
alert("this is a IE");
else
alert("this is a Firefox");
//-->
</SCRIPT>
@Feuda
Feuda / jdbcdemo01.jsp
Created March 2, 2011 09:12
JDBC连接Mysql数据库
<%@ page contentType="text/html;charset=gbk"%>
<%@ page import="java.sql.*"%>
<%
// 定义数据库驱动程序,"com.mysql.jdbc.Driver"不用更改,适用于所有mysql程序
String DBDRIVER = "com.mysql.jdbc.Driver" ;
// 定义数据库连接地址,"jdbc:mysql://localhost:3306/你的数据库名称",前面同样适用所有mysql程序,后面是你的数据库名称
String DBURL = "jdbc:mysql://localhost:3306/feuda" ;
// 定义数据库连接对象,属于java.sql包中的接口,所以才有<%@ page import="java.sql.*"%>这一步
Connection conn = null ;
// 定义Statement对象,用于操作数据库
@Feuda
Feuda / 选择排序升序算法
Created October 31, 2010 16:29
选择排序
public class Example13 {
public void selectionSort(int[] arr) {
int minIndex;
int t;
for (int i = 0; i < arr.length - 1; i++) {
minIndex = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[j] < arr[minIndex]) {
minIndex = j;
@Feuda
Feuda / System.in.read & 数组
Created October 31, 2010 15:37
看如何输入数组
public class Example12 {
public void input(int[] arr) {
System.out.println("请输入5个整数,每输入一个请按回车键:");
try {
byte[] buf = new byte[20];
for (int i = 0; i < arr.length; i++) {
System.in.read(buf);
String str = new String(buf);
@Feuda
Feuda / 给定年、月,用Java算出当月有多少天
Created October 29, 2010 16:30
重点一个月多少天里的规律
public class BreakInSwitch {
public int days(int year, int month) {
int days = 0;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
Try it