This file contains hidden or 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
public class FinallyExample { | |
public static void main(String[] args) { | |
System.out.println(foo("1")); | |
System.out.println(foo("a")); | |
} | |
public static int foo(String numStr) { | |
try { | |
int x = Integer.parseInt(numStr); |
This file contains hidden or 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
from bisect import bisect_left | |
def index(a, x): | |
'Locate the leftmost value exactly equal to x' | |
i = bisect_left(a, x) | |
if i != len(a) and a[i] == x: | |
return i | |
raise ValueError | |
def get_journey(departure_ids, destination_ids): |
This file contains hidden or 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
def tuple_sum(a, s): | |
ret = backtrack(a, s, 0, 1, 2, 3) | |
print ' '.join(str(i) for i in ret) | |
def backtrack(a, s, x, y, w, z): | |
result = a[x] + a[y] + a[w] + a[z] | |
conj = set([x, y, w, z]) | |
if result == s and len(conj) == 4: |
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
import os | |
import errno | |
from time import sleep | |
FIFO_PATH = "/etc/scripts/ipc" | |
MESSAGE="libvirtd-restart\n" | |
SLEEP_SECS=2 |
This file contains hidden or 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 <sys/types.h> | |
#include <dirent.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <sys/stat.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include <unistd.h> | |
#include <signal.h> |
This file contains hidden or 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.brauto.automacao.device.usb; | |
import android.app.Service; | |
import android.content.Intent; | |
import android.os.Handler; | |
import android.os.IBinder; | |
import android.util.Log; | |
import com.brauto.automacao.MyApp; | |
import com.googlecode.androidannotations.annotations.EService; |
This file contains hidden or 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
int led = 13; | |
int incomingByte = 0; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize serial communication at 9600 bits per second: | |
Serial.begin(9600); | |
pinMode(led, OUTPUT); | |
} |
This file contains hidden or 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
Index: src/test/br/ufrj/gnosys/framework/mock/FakeLogin.java | |
=================================================================== | |
--- src/test/br/ufrj/gnosys/framework/mock/FakeLogin.java (revision 3079) | |
+++ src/test/br/ufrj/gnosys/framework/mock/FakeLogin.java (working copy) | |
@@ -1,15 +1,23 @@ | |
package br.ufrj.gnosys.framework.mock; | |
+import java.util.HashSet; | |
+ | |
+import javax.persistence.EntityManager; |
This file contains hidden or 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
pop=list(raw_input("digite uma palavra: ")) | |
print len(pop),"numero de caracteres da palvra" | |
print pop[0],"e a primeira letra da plavra" | |
print pop[-1],"e a ultima letra da palavra" | |
for i in range(len(pop)): | |
caracter = pop[i] | |
if caracter == 'a' or caracter == 'e' or caracter == 'i' or caracter == 'o' or caracter == 'u': | |
pop[i] = ' ' |
This file contains hidden or 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 numpy as np | |
# matriz de transicoes | |
P = np.array([[0.0, 1.0/3, 1.0/3, 1.0/3], [0.0, 0.0, 0.0, 1.0], [1.0/2, 0.0, 0.0, 1.0/2], [0.0, 0.0, 1.0, 0.0]]) | |
def sistema_linear(): | |
# declarando matriz original | |
A_original = np.array([[1.0,-(1.0/2),0.0,0.0], [-1.0/3,1.0,0.0,0.0], [-1.0/3,0.0,1.0,-1.0], [-1.0/3, -1.0, -1.0/2, 1.0]]) | |
# substituindo a primeira linha por [1, 1, 1, 1] para podermos resolver o sistema |
NewerOlder