Skip to content

Instantly share code, notes, and snippets.

@lenamuit
lenamuit / my_controller.php
Created May 6, 2012 09:48
Cakephp: add/edit/delete record
function admin_add(){
//TODO: check retype password
if (!empty($this->data)){
$this->Product->set($this->data);
if ($this->Product->validates()){
if ($this->Product->save($this->data)){
$this->Session->setFlash("Add member successfull");
}
else{
$this->Session->setFlash("Add member fail");
@lenamuit
lenamuit / pom.xml
Created August 21, 2013 05:23
fix error --core-android when using google api libs
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.16.0-rc</version>
<exclusions>
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
<exclusion>
@lenamuit
lenamuit / gist:10008211
Created April 6, 2014 16:17
Error log when convert erb to haml (gem erb2haml)
/home/lenam/Projects/Website/test_rails/app/views/home/index.html.haml:24: syntax error, unexpected end-of-input, expecting keyword_end:
actionpack (3.2.12) lib/action_view/template.rb:297:in `'
actionpack (3.2.12) lib/action_view/template.rb:297:in `module_eval'
actionpack (3.2.12) lib/action_view/template.rb:297:in `compile'
actionpack (3.2.12) lib/action_view/template.rb:244:in `block in compile!'
actionpack (3.2.12) lib/action_view/template.rb:232:in `synchronize'
actionpack (3.2.12) lib/action_view/template.rb:232:in `compile!'
actionpack (3.2.12) lib/action_view/template.rb:144:in `block in render'
activesupport (3.2.12) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.12) lib/action_view/template.rb:143:in `render'
@lenamuit
lenamuit / rack_utils.rb
Last active August 29, 2015 14:02
HTTP_STATUS_CODES
HTTP_STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
@lenamuit
lenamuit / TakeImageFromView.java
Created June 7, 2014 11:15
Take image from View and share
Bitmap screenshot = Bitmap.createBitmap(_rootView.getWidth(), _rootView.getHeight(), Bitmap.Config.RGB_565);
_rootView.draw(new Canvas(screenshot));
String path = Images.Media.insertImage(getContentResolver(), screenshot, "title", null);
Uri screenshotUri = Uri.parse(path);
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
@lenamuit
lenamuit / google_now_card.xml
Created June 9, 2014 16:47
Google Now card background
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp"/>
<solid android:color="#ccc" />
@lenamuit
lenamuit / .zshrc
Created June 10, 2014 03:42
zshrc config
# type "go filename" to open the file by default application
alias go='xdg-open'
@lenamuit
lenamuit / android-studio.desktop
Created June 13, 2014 02:47
/usr/share/applications/android-studio.desktop
[Desktop Entry]
Name=Android Studio
Comment=IDE for Android development
Type=Application
Categories=Development;IDE;
Exec=/home/user/Downloads/android-studio/bin/studio.sh
Terminal=false
StartupNotify=true
Icon=/home/user/Downloads/android-studio/bin/idea.png
Name[en_US]=Android Studio
@lenamuit
lenamuit / manifest.xml
Created June 21, 2014 02:40
Intent-filter for Browser
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>
@lenamuit
lenamuit / HogeCipher.java
Last active August 29, 2015 14:04
encryptAES with iv parameter
public class HogeCipher {
private static final String keyString = "<your secret key>"
public static String encryptString(String ivString, String input)
throws
java.io.UnsupportedEncodingException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
InvalidAlgorithmParameterException,