Skip to content

Instantly share code, notes, and snippets.

@fdb713
fdb713 / gist:4611033
Created January 23, 2013 17:56
codeigniter check username when logging in using ajax
<?php
function ajax_lookUpUsername(){
$username = $this->input->post('username');
$this->db->where('username', $username);
$query = $this->db->get('accounts');
if ($query->num_rows() > 0){
echo 0;
} else {
echo 1;
}
@fdb713
fdb713 / gist:4673119
Last active December 11, 2015 22:58
min stored procedure of pagination
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `paginate`(
in _table varchar(100),
in _where varchar(100),
in _order_by varchar(100),
@fdb713
fdb713 / gist:5185754
Created March 18, 2013 08:30
date and time sync on centos
#!/bin/bash
yum install -y ntp
ntpdate 0.centos.pool.ntp.org
sleep 3
hwclock --systohc
@fdb713
fdb713 / gist:06d1d5b5e98a70939eb6
Last active December 16, 2015 14:39
nginx if two condition
if ($request_uri ~ "\.htm")
{
set $my_cond P;
}
if ($args){
set $my_cond "${my_cond}C";
}
if ($my_cond = PC)
{
return 403;
@fdb713
fdb713 / twitter.mute.js
Last active December 17, 2015 03:09
mute tweets containing specific keyword.
// origin: @ayanamist
// ==UserScript==
// @name Twitter Timeline URL Expand
// @namespace Twitter-Timeline-URL-Expand
// @description Replace t.co href of A tag with real url.
// @match http://twitter.com/*
// @match https://twitter.com/*
// @version 1.1
// ==/UserScript==
(function (window) {
@fdb713
fdb713 / vimrc.vim
Last active December 22, 2015 03:29
vimrc
" https://github.com/sontek/dotfiles/
" ==========================================================
" Dependencies - Libraries/Applications outside of vim
" ==========================================================
" Pep8 - http://pypi.python.org/pypi/pep8
" Pyflakes
" Ack
" nose, django-nose
" ==========================================================
@fdb713
fdb713 / xiami.py
Created November 20, 2013 07:50
xiami.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
File: xiami.py
Author: Luigi Fan
Description: Auto check-in script for xiami.
'''
import requests
import re
@fdb713
fdb713 / v2ex_checkin.py
Last active May 25, 2016 05:27
v2ex checkin
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
username = 'username'
password = 'password'
login_url = 'http://v2ex.com/signin' ###如V2EX设置了使用 SSL,必须改 https###
index_url = 'http://v2ex.com' ###同上###
mission_url = 'http://www.v2ex.com/mission/daily' ###同上###
@fdb713
fdb713 / ydcv.rb
Last active May 3, 2018 12:43
肥猫的有道声优(大雾)homebrew打包
require 'formula'
class Ydcv < Formula
homepage 'https://github.com/felixonmars/ydcv'
url 'https://github.com/felixonmars/ydcv/archive/master.zip'
version '0.0.1'
head 'https://github.com/felixonmars/ydcv'
def install
bin.install "src/ydcv.py" => "ydcv"
@fdb713
fdb713 / mid3iconv.py
Created March 10, 2015 08:56
mid3iconv
#!/usr/bin/env python
# ID3iconv is a Java based ID3 encoding convertor, here's the Python version.
# Copyright 2006 Emfox Zhou <EmfoxZhou@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
import sys
import locale