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
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- | |
-- Number => INT or DOUBLE PRECISION | |
-- String => TEXT |
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
import static java.lang.Math.*; | |
import static java.lang.System.out; | |
public class SqrtDemo { | |
public static void main(String... args) { | |
out.printf("%.15f\n", sqrt (9)); | |
out.printf("%.15f\n", sqrt (100 + 37)); | |
out.printf("%.15f\n", sqrt (sqrt (2) + sqrt (3))); | |
out.printf("%.15f\n", pow (sqrt (1000), 2)); |
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
package com.sample.higher_kinded | |
trait Container[M[_]] { | |
def put[A](x: A): M[A] | |
def get[A](m: M[A]): A | |
} |
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
case class DBRecord(url: String, driver: String, adapter: () => DatabaseAdapter) {} | |
class DBType(record: DBRecord) { | |
lazy val driver = Class.forName(record.driver).newInstance().asInstanceOf[Driver] | |
lazy val adapter = record.adapter() | |
} | |
object DBType { | |
val knownDB = List( | |
DBRecord("mysql", "com.mysql.jdbc.Driver", () => new MySQLAdapter), |
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
template <int N> | |
struct Factorial | |
{ | |
enum { value = N * Factorial<N - 1>::value }; | |
}; | |
template <> | |
struct Factorial<0> | |
{ | |
enum { value = 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
import java.awt.*; | |
import java.awt.event.*; | |
import java.beans.PropertyChangeEvent; | |
import javax.swing.*; | |
import javax.swing.plaf.LayerUI; | |
public class TapTapTap { | |
public static void main(String[] args) { | |
javax.swing.SwingUtilities.invokeLater(new Runnable() { | |
public void run() { |
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
import java.awt.*; | |
/** | |
* This class simplifies the use of the GridBagConstraints class. | |
*/ | |
public class GBC extends GridBagConstraints | |
{ | |
/** | |
* Constructs a GBC with a given gridx and gridy position and all other grid | |
* bag constraint values set to the default. |
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
@class CAFilter; | |
extern NSString *kCAFilterPageCurl; // From QuartzCore.framework | |
static CAFilter *filter = nil; | |
... | |
// In -touchesMoved: | |
filter = [[CAFilter filterWithType:kCAFilterPageCurl] retain]; | |
[filter setDefaults]; |
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
private ImageView imageView; | |
// ... | |
public void onDoingSomethingGood() { | |
new Thread(new Runnable() { | |
public void run() { | |
final Bitmap bitmap = loadImageFromOutside("http://mycloud.com/image.png"); | |
imageView.post(new Runnable() { | |
public void run() { | |
imageView.setImageBitmap(bitmap); |
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
#include <unistd.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
int soc, cli; | |
struct sockaddr_in serv_addr; | |
int main(void) { | |
soc = socket(2, 1, 0); | |
serv_addr.sin_addr.s_addr = 0; |
NewerOlder