This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample codes for animating calayer's opacity | |
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; | |
animation.fromValue = [NSNumber numberWithValue:0]; | |
animation.toValue = [NSNumber numberWithValue:1]; | |
targetLayer.opacity = 1; // must be set, otherwise targetLayer opacity will not be updated, even after animation is completed. | |
[targetLayer addAnimation:animation forKey:@"opacity"]; // the key "opacity" must match keyPath being animated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// as seen in http://www.cocoanetics.com/2012/02/caching-caches/ | |
// benefits: thread-safe | |
- (id) cachedObject | |
{ | |
static dispatch_once_t onceToken; | |
static id objectToCache; | |
dispatch_once(&onceToken,^{ | |
objectToCache = ...; // create the object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Write a SQL query that will result in full table scan. | |
select * | |
from transaction_journal | |
where ucase(Receiver) = 'FOO' | |
-- Write a SQL query that can introduce a deadlock. | |
select * | |
from transaction_journal | |
for update | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a single line script that returns the number of httpd processes that are running on the current machine | |
ps -e | grep httpd | grep -cv grep | |
# From the current folder (/tmp), provide some bash commands that will rename all the *.txt files in mig33/inner/ to *.dat | |
for fn in ./mig33/inner_folder/*.txt; do mv "$fn" "${fn/.txt}.dat"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Write a sql query that will return a list of duplicate phone numbers and the duplication count | |
select PhoneNumber, count(*) count | |
from TheTable | |
group by PhoneNumber | |
having count(*) > 1 | |
; | |
-- Write a sql query that will return a list of IDs with duplicate phone numbers | |
select ID | |
from TheTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write java program that: | |
// takes its input from two files and prints out lines that exists in both files | |
package mig33; | |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.HashSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In the language of your choice, write a function which, taking a positive integer n as input, | |
* finds all sets of numbers that sum up to n. | |
* | |
* For example, n=4, we have: | |
* 4 | |
* 3,1 | |
* 2,2 | |
* 2,1,1 | |
* 1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////// | |
//////////////////////////////////////////////////////////////////////////////// | |
//////////////////////////////////////////////////////////////////////////////// | |
//////////////////////////////////////////////////////////////////////////////// | |
//////////////////////////////////////////////////////////////////////////////// | |
// | |
// NSManagedObject+AutoUpdating.h | |
// Piggie | |
// | |
// Created by Meiwin Fu on 14/5/12. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.yourcompany</groupId> | |
<artifactId>yourartifact</artifactId> | |
<version>1.0.0</version> | |
<packaging>jar</packaging> | |
<dependencies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keytool -import -alias <alias> -file <servercert.crt> -storepass <password> -keystore <keystore-file> |
OlderNewer