Skip to content

Instantly share code, notes, and snippets.

@lyonsun
lyonsun / nginx.conf
Created October 29, 2013 03:21
nginx config for codeigniter, but this doesn't work for me.
server_name localhost;
root "E:\LYON\NGINX\citestonginx";
index index.html index.php;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
@lyonsun
lyonsun / .htaccess
Created November 21, 2013 01:52
force ssl connection. .htaccess setting.
RewriteEngine On
RewriteCond %{HTTPS} =off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html|php)
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$
RewriteRule ^(index\.(html|php))|(.*)$ https://www.%2/$3 [R=301,L]
@lyonsun
lyonsun / wordwrap.css
Created November 26, 2013 05:32
css to break long line down. word-wrap text.
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
@lyonsun
lyonsun / curlreqres.php
Last active December 29, 2015 12:19
using Curl to post request to external api.
<?php
// here is where you are going to post curl.
$test_url = "www.example.com";
// this is the content to be post.
$request_xml_content = "<request>this is a sample xml request</request>";
// init Curl call.
$ch = curl_init();
// set options for Curl.
@lyonsun
lyonsun / xmlHttpReq_init.js
Created November 27, 2013 03:16
cross-browser XMLHttpRequest instantiation
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject () {
var xmlHttp;
if (window.ActiveXObject) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = false;
@lyonsun
lyonsun / anchor_touch.js
Last active December 31, 2015 05:09
prevent anchor link drag-drop and redirect link on touch screen.
// prevent text selection in IE
document.onselectstart = function () { return false; };
// prevent anchor link drag.
$('selector').mousedown(function(event) {
event.preventDefault();
});
// redirect link.
$('selector').mouseup(function(event) {
@lyonsun
lyonsun / index.html
Created January 22, 2014 07:54
get innerHTML of option in select element.
<html>
<head>
<title>HTML BASIC</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<style type="text/css" media="screen">
body {
color: red;
}
</style>
</head>
@lyonsun
lyonsun / .htaccess
Created February 18, 2014 08:44
codeigniter, remove index.php from url, add this file under application root directory.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
@lyonsun
lyonsun / mobile.js
Created February 22, 2014 07:53
javascript, detect if it is mobile
var windowWidth = window.screen.width < window.outerWidth ?
window.screen.width : window.outerWidth;
var mobile = windowWidth < 500;
@lyonsun
lyonsun / navbar-fixed-top.js
Created March 8, 2014 14:45
bootstrap, make navbar stick to top when scrolling down
function setSkrollr(){
var objDistance = $navbar.offset().top;
$(window).scroll(function() {
var myDistance = $(window).scrollTop();
if (myDistance > objDistance){
$navbar.addClass('navbar-fixed-top');
}
if (objDistance > myDistance){
$navbar.removeClass('navbar-fixed-top');
}