Skip to content

Instantly share code, notes, and snippets.

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
public class GcmIntentService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
sendNotification(extras.getString("descricao"), extras.getString("endereco"));
}
(def second (fn [list] (nth list 1) ))
(def square (fn [n] (n * n)))
(def sum (fn [list] (apply + list)))
(def add-square (fn [list] (sum (map square list)) ))
(def fac (fn [n] (apply * (range 1 (+ n 1) ))))
(def fatorialT
(fn [n acc]
(if (= n 0)
acc
(fatorialT (dec n) (* acc n)))))
(prn (fatorialT 5 1))
(def rec
(fn [n acc]
(if (empty? n)
acc
(recur (rest n) (+ acc (first n))))))
(prn (rec [4 3 2 1] 0))
(def rec
(fn [f numbers acc]
(if (empty? numbers)
acc
(recur f (rest numbers) (f acc (first numbers))))))
(prn (rec * [4 2 3] 1 ))
(defn x [map key]
(conj map {key (count map)}))
(defn rec [f numbers acc]
(if (empty? numbers)
acc
(recur f (rest numbers) (f acc (first numbers)))))
(prn (rec x [:a :b :c] {} ))
@renanreismartins
renanreismartins / ->.clj
Created October 29, 2014 06:59
-> operator exe 4
(+ (* (+ 1 2) 3) 4)
(-> (+ 1 2) (* 3) (+ 4))