import RPi.GPIO as GPIO from time import sleep PIN18 = 12 PIN25 = 22 GPIO.setmode(GPIO.BOARD) GPIO.setup(PIN25, GPIO.IN) GPIO.setup(PIN18, GPIO.OUT) LEDON = False while 1: try: if GPIO.input(PIN25): if LEDON == True: print “– PIN25 ON” LEDON = False GPIO.output(PIN18, False) else: print “– PIN25 OFF” LEDON = True GPIO.output(PIN18, True) sleep(1) except KeyboardInterrupt: GPIO.cleanup()…
Year: 2013
Magento – rules to fix catalog price rule price
Refer http://www.pacificwebtechnology.com/blog/magento-rules-to-fix-catalog-price-rule-issue/ 1. Make pricerule.php in root folder <?php require_once ‘app/Mage.php’; // if your are not root folder then write the proper path like publichtml/magento/app/Mage.php Mage::app(‘default’); $catalogRule = Mage::getModel(‘catalogrule/rule’); $catalogRule->applyAll(); Mage::app()->removeCache(‘catalog_rules_dirty’); ?> 2. Make cron job 0 0 * * * php /home/~/public_html/pricerule.php
Make Retina display ready for input submit button with image
When use input[type=image] for form submission, the image is stretched when use Retina Display mobile. Since you cannot change ‘src’ attribute using CSS, I had to find another way to accomplish this. Someone said to use ‘content’ in CSS can do, but I failed. And this method is not browser compatible. Anyway, you can make…
.htaccess to force browsers to display a download dialog for non-image files
.htaccess to force browsers to display a download dialog for non-image files Reference: jQuery File Upload # The following directives force the content-type application/octet-stream # and force browsers to display a download dialog for non-image files. # This prevents the execution of script files in the context of the website: ForceType application/octet-stream Header set Content-Disposition…
Media Query Reporter CSS Injection
Ref: http://webdesigntutsplus.s3.amazonaws.com/tuts/221_responsive_widget/Media-Query-Files-DEMO/index.html <link rel=”stylesheet” type=”text/css” media=”screen” href=”http://webdesigntutsplus.s3.amazonaws.com/tuts/221_responsive_widget/Media-Query-Files-DEMO/styles-mediaquery-reporter.css” /> Code Only: /* ====================================== MediaQuery-Reporter Styles ========================================= */ body:after { content: “less than 320px”; font-size: 300%; font-weight: bold; position: fixed; bottom: 60px; width: 100%; text-align: center; background-color: hsla(1,60%,40%,0.7); color: #fff; } @media only screen and (min-width: 320px) { body:after { content: “320 to 480px”; background-color: hsla(90,60%,40%,0.7);…
WordPress JSON API – Support since(from) date/time
WordPress JSON API (http://wordpress.org/plugins/json-api/) is a powerful plugin that allows RESTful API for WordPress. However, I needed specific post query such as “Get posts since 1999/01/01 11:00:00”, which JSON API did not support. After doing hours research to do so, I couldn’t find relavant answers. Since JSON API uses WP_Query in WordPress, I thought I…
[PPStream – Mac] Watching PPS outside of China
To watch PPS outside of China, add below lines to /private/etc/hosts 127.0.0.1 update.111222.cn 127.0.0.1 msg.ppstream.com Reference: http://www.weste.net/2006/10-24/09394857669.html Alternatively, can use Chrome with extension called “Unblock Youku“. This extension will allow to watch Youku, Tudou, PPS Web, Qiy, and so on from outside of China. https://chrome.google.com/webstore/detail/unblock-youku/pdnfnkhpgegpcingjbfihlkjeighnddk
Aptana Increase Memory Size & Excluding unnecessary files
Mac Application -> Aptana Studio 3 -> Click “AptanaStudio3.app” -> Right Click “Show Package Contents” -> Contents -> MacOS -> Open “AptanaStudio3.ini” with any text editor 1. –launcher.XXMaxPermSize 512m 2. -Xms512m 3. -Xmx1024m -startup ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar –launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.1.101.v20120109-1504 –launcher.XXMaxPermSize 512m –launcher.defaultAction openFile -vmargs -Xms512m -Xmx1024m -Declipse.p2.unsignedPolicy=allow -Declipse.log.size.max=10000 -Declipse.log.backup.max=5 -Xdock:icon=../Resources/aptana.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts Windows Go to C:\Users\Chris\AppData\Local\Aptana Studio…
Using KML file for iOS Simulator
(Before beginning, there may be other ways to use KML. I am just beginner in iOS programming and this is how I work around.) XCode allows to simulate the locations using GPX file type. One of location tracker, Google Latitude, allows to download recorded locations to KML file type. To use KML file for iOS…
XCode crash every second time.
I have XCode 4.6.2 (4H1003) and MBP retina. When I run my project in simulator, it crashes every second running without any error message in debug console. return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); The error is “Thread 1: signal SIGABRT“. Annoyingly, XCode does not give any error. According to the this guy, it is because of…
To use ‘messageComposeViewController’
To use ‘messageComposeViewController’ Add “MessageUI.framework” Library And should define on “AppDelegate.m” #import <MessageUI/MessageUI.h>
To re-size images with keeping aspect ratio and fitting to certain dimensions
To re-size images with keeping aspect ratio and fitting to certain dimensions function _create_thumbnail($actual_filepath, $folder_path, $target_filename, $width, $height) { // $this->load->library(‘image_lib’); // $image_lib_config = array( // ‘image_library’ => ‘gd2’ // , ‘source_image’ => $actual_filepath // , ‘new_image’ => $folder_path.$target_filename // , ‘maintain_ratio’ => true // , ‘width’ => $width // , ‘height’ => $height //…
New Expiry Date for CBA, ANZ, NAB Test Credit Card
New expiry date for test credit card number is 05/17. Card Number Expiry Date CVN Description 5123456789012346 05/17 123 MasterCard 4313581000123430 …
Where is “UIViewController subclass”?
In latest XCode (v4.6.2), I couldn’t find “UIViewController”, which tutorial book wants me to choose. According to this article, choose “Object-C Class” instead of.
구글 드라이브 사용법
구글 드라이브 사용법 이 문서는 구글 드라이브 사용법에 대해서 설명하기 위해 제작되었습니다. 구글 드라이브란? 구글 드라이브란 구글에서 제공하는 클라우드 문서 관리/공유 서비스입니다. 구글드라이브에서 제작할 수 있는 문서 형식은 워드, 엑셀등이 있으며, 동시에 접속하여 수정이 가능하며 자동으로 클라우드 서버에 저장이 됨과 동시에 히스토리를 남겨 작성 도중 유실된 염려가 없습니다. 또한 모바일 어플리케이션도 제공함으로 언제 어디서든지 실시간으로…
SQLite – could not prepare statement (1 too many SQL variables)
During development for SQLite, I have got this error could not prepare statement (1 too many SQL variables) Accroding to this article, this error is because of SQLite limitation, which cannot put variables more than 999 variables. After I reduce the amount of variables, it worked very well.
deprecated! ‘UILineBreakModeCharacterWrap’ & ‘UITextAlignmentCenter’
When I use UILineBreakModeCharacterWrap, I get this message ‘UILineBreakModeCharacterWrap’ is deprecated use NSLineBreakByCharWrapping instead of it. //[label setLineBreakMode:UILineBreakModeCharacterWrap]; [label setLineBreakMode:NSLineBreakByCharWrapping]; If I use UITextAlignmentCenter, then I get ‘UITextAlignmentCenter’ is deprecated: first deprecated in iOS 6.0 use NSTextAlignmentCenter instead of: //[textLabel setTextAlignment:UITextAlignmentCenter]; [textLabel setTextAlignment:NSTextAlignmentCenter];
Python – ImportError: No module named django.utils
When I follow the tutorial – App Engine Series #4 – I got this error for Ajax.py: ImportError: No module named django.utils According to this article, Python 2.7 uses native JSON library. Fixed source for Ajax.py is this: #!/usr/bin/env python # -*- coding: utf-8 -*- # Including the models: from models.models import * # from Phyton 2.7,…
Python – ImportError: No module named
When I follow the tutorial – App Engine Series #4 – I kept getting the error like below: ImportError: No module named controllers It is caused by below code: import webapp2 # Importing the controllers that will handle # the generation of the pages: from controllers import crons,ajax,generate,mainh To fix the error, it is very simple….
Google App Engine Tutorial – Datastore – 한글 입력시 Internal Server Error 나는 현상
Google App Engine의 Datastore 튜토리얼 소스를 실행시 한글을 방명록 이름(Guestbook name)필드에 입력하면 다음과 같은 에러가 발생한다. Traceback (most recent call last): File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py”, line 1535, in __call__ rv = self.handle_exception(request, response, e) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py”, line 1529, in __call__ rv = self.router.dispatch(request, response) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py”, line 1278, in default_dispatcher return route.handler_adapter(request, response) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py”, line 1102,…
Python – 한글로 주석 남기면 실행 안되는 현상(cannot execute app if write Korean as comment)
한글로 코멘트를 남겼는데 다음과 같은 서버 에러가 발생했다. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. 검색해서 Using Python with Chinese, Japanese and Korean 라는 글을 찾았고, 코드를 다음과 같이 하니 문제없이 실행되었다. #!/usr/bin/env python # -*- coding: utf-8 -*-
Sample Code from Developing and deploying an application on Google App Engine
In the video, it provides the code as below #!/usr/bin/env python import os import wsgiref.handlers from google.appengine.ext import webapp from google.appengine.ext.webapp import template class MyHandler(webapp.RequestHandler): def get(self): self.response.out.write(template.render(‘main.html’, {})) def main(): app = webapp.WSGIApplication([ (r’.*’, MyHandler)], debug= True) wsgiref.handlers.CGIHandler().run(app); if __name__ == “__main__”: main() However, it gives the error as below: Traceback (most recent call…
Bootstrap Modal Remote Example
Reference: http://twitter.github.com/bootstrap/javascript.html#modals Reference: http://jsfiddle.net/mmfansler/cp67J/ <a data-target=”#myModal” role=”button” class=”btn” data-toggle=”modal”>Launch demo modal</a> <div class=”modal fade hide” id=”myModal” tabindex=”-1″ role=”dialog” aria-labelledby=”myModalLabel” aria-hidden=”true” data-remote=”/mmfansler/aQ3Ge/show/”> <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-hidden=”true”>×</button> <h3 id=”myModalLabel”>Modal header</h3> </div> <div class=”modal-body”> <p>One fine body…</p> </div> <div class=”modal-footer”> <button class=”btn” data-dismiss=”modal” aria-hidden=”true”>Close</button> <button class=”btn btn-primary”>Save changes</button> </div> </div>
Draw Polygons in Google Maps and Determine whether an Address is in Polygons
Draw Polygons in Google Maps and Determine whether an Address is in Polygons This sample source code uses Google Maps Javascript API V3 to draw polygons in Google Maps. (Refer https://google-developers.appspot.com/maps/documentation/javascript/examples/drawing-tools) The address auto-complete uses Google Places Javascript library. (Refer https://developers.google.com/maps/documentation/javascript/places#places_autocomplete) The server-side code will retrieve address’ latitude and longitude using Google Gecoding API. (Refer…