반응형

Just discovered how super simple it was to add some gz compression when for example providing JSON data from PHP.

All you need is regular output buffering with the ob_gzhandler as output callback.

// Fetch some data
$data = get_data();

// Turn on output buffering with the gzhandler
ob_start('ob_gzhandler');

// Output as normal
echo json_encode($data);

The cool thing is that it actually looks at what the browser accepts before doing anything.

Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept (“gzip”, “deflate” or none at all) and will return its output accordingly. All browsers are supported since it’s up to the browser to send the correct header saying that it accepts compressed web pages.

Tried adding it for a text field with timezone auto-completing for example, and without this handler:

Content-Length    5517
Content-Type      application/json

With this handler:

Content-Encoding  gzip
Vary              Accept-Encoding
Content-Length    1775
Content-Type      application/json

Do like! 😆

반응형
반응형

 

 

ios app 을 웹 어플리케이션에서 킬때... 사파리에서는 안먹히는 것 해결

반응형
반응형

<p class="price display_custom{$product_custom}"><strike>{$disp_product_custom}</strike></p>

 

위 소스 추가 후 css 에

 

/* 소비자가 0원시 비노출 */

.display_custom { display:none; }

.display_custom0 { display:none; }

 

추가

반응형
반응형

jquery-ui 의 dialog close 버튼이 안보일때

bootstrap.min.js 와 스크립트 충돌로 인한것으로 해당 스크립트를 우선순위를 바꾸거나 제외하면 정상적으로 보인다.

반응형
반응형

var url_regex = /(http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?)/gi;
var email_regex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi;

 

var string = "도메인은 http://www.huzy.net/ 이고 이메일은 root@yjhoon.com 입니다.";

 

var url_result = string.match(url_regex);

=> ["http://www.huzy.net/"]

 

var email_result = string.match(email_regex);

=> [root@yjhoon.com"]

 

 

result 값은 둘다 배열로 리턴되서 나옴 .

반응형
반응형

기본적으로 HttpSessionListener를 구현(Implements)하여 세션이 생성 되는 시점과 세션이 사라지는 시점을 가지고 올 수 있다.

세션을 생성 되는 시점에 DB나 특정 Static 변수에 세션 정보를 저장 하고 세션이 종료될 때 그 세션 정보를 지워 줌으로써

해당 세션의 중복 로그인을 막을 수 있으며 현재 접속중이 접속자 정보를 가지고 올 수 있다.

package com.moainfo.http.session;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MoaSessionListener implements HttpSessionListener
{
 public void sessionCreated(HttpSessionEvent se)
 {
  HttpSession session = se.getSession();
  System.out.println("Create session : " + session.getId());
 }
 public void sessionDestroyed(HttpSessionEvent se)
 {
  HttpSession session = se.getSession();
  System.out.println("Close session : " + session.getId());
  
 }
}

 


출처 - http://definejava.net/


===================================================================================


HttpSessionBindingListener vs HttpSessionListener

HttpSessionBindingListener 는 이 인터페이스를 임플리먼츠한 객체를 세션에 바인딩 시키거나 언바인딩 될때 이벤트가 발생합니다. 반면에 HttpSessionListener 인터페이스는 톰캣의 web.xml에 리스너로서 등록을 하면 해당사이트에서 세션이 생성될때 ,글구 소멸될때 발생합니다. 순수한 세션 카운팅을 할때 꼭 필요합니다. ^^;;


출처 - http://www.okjsp.pe.kr/seq/28283


반응형
반응형

무슨 이야기인가 하면 예를 들어 webmini.net 로 접속했을때와 www.webmini.net 그리고 카페24 호스팅 같은 경우 backzzanggu.cafe24.com 으로 접속했을때 자동으로 www.webmini.net 한곳으로 접속되게 하는 팁입니다.

알ftp에서 숨김파일로 되어있어 보이지 않는 파일을 상단메뉴 옵션 > 환경설정에서 숨긴파일을 볼수 있게 설정한후
.htaccess 파일을 메모장으로 연후 2~4 줄에 아래소스를 추가해 줍니다.

RewriteCond %{HTTP_HOST} !^www\.webmini\.net$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://www\.webmini\.net/$1 [L,R]

쉽게 말하면 RewriteEngine On 아래에 위에 소스를 추가하는 것입니다.
그럼 www 붙히지 않고 접속해도 자동으로 www 가 붙어서 연결되는걸 확인할수 있습니다.
주소는 각자 구매하신 도메인 주소로 수정하세요.(아래소스 참고)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.webmini\.net$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://www\.webmini\.net/$1 [L,R]
</IfModule>


ps. 혹시 모르니 백업해두시기 바라며, cafe24 같은 경우 이상없이 접속 되었습니다.

http://webmini.net
http://backzzanggu.cafe24.com


위 주소로 접속해 보세요.^^

이렇게 해줘야 webmini.net 으로 로그인했을때 www.webmini.net 으로 들어가면 로그인이 풀려있는것을 방지할수도 있답니다.

출처 : [XE(XpressEngine)] : 웹미니 (http://www.webmini.net/?mid=xe&document_srl=17467)

 

 

 

+ 자바스크립트로 처리시

<script  language="JavaScript" type="text/javascript">
 var host = location.host.toLowerCase();
 var currentAddress = location.href;
 if (host.indexOf("www") == -1)
 {
  currentAddress = currentAddress.replace("//","//www.");
  location.href = currentAddress;
 }
</script>

 

반응형

'웹프로그래밍' 카테고리의 다른 글

Huzy TOOLS 를 시작.  (0) 2024.01.02
Conditional comments with IE  (0) 2015.04.17
MySQL 수정  (0) 2014.06.28
웹폰트 완벽 사용법? (woff, eot)  (0) 2014.03.08
XE 템플릿 구문  (0) 2014.02.18
반응형

$functionName() or call_user_func($functionName)

반응형

+ Recent posts