Skip to content

Instantly share code, notes, and snippets.

@shenyute
shenyute / fcm.js
Created January 3, 2021 11:18
fcm
var admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.applicationDefault(),
// databaseURL: 'https://<DATABASE_NAME>.firebaseio.com'
});
// This registration token comes from the client FCM SDKs.
var registrationToken = '<token>';
var message = {
class Storage:
"""Note bucket is the prefix to identify object usage"""
def save(self, bucket: str, file_name: str, expire_time: long):
"""save file to bucket with file_name"""
pass
def delete(self, bucket: str, file_name: str) -> bool:
"""delete file of bucket"""
pass
def get(self, bucket: str, file_name: str) -> bytes:
"""get file from bucket"""
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
@shenyute
shenyute / trace.c
Created December 23, 2016 02:33
ptrace example
#include <sys/ptrace.h>
#include <bits/types.h>
#include <sys/user.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
-Thread 1- -Thread 2- -Thread 3-
y.store (20); if (x.load() == 10) { if (y.load() == 10)
x.store (10); assert (y.load() == 20) assert (x.load() == 10)
y.store (10)
}
@shenyute
shenyute / Test
Created September 15, 2016 03:48
import java.util.ArrayList;
import java.util.List;
public class Foo
{
class NaturalNumber {
private int i;
public NaturalNumber(int i) { this.i = i; }
#include <iostream>
class Base
[27979:27977:1128/105637:235776252141:INFO:CONSOLE(13)] "
0000000 000 0000000
111111111 11111111100 000 111111111
00000 111111111111111111 00000 000000
000 1111111111111111111111111100000 000
000 1111 1111111111111111100 000
000 11 0 1111111100 000
000 1 00 1 000
000 00 00 1 000
000 000 00000 1 000
#if defined(OS_ANDROID)
// Though Android has a "helpful" process called debuggerd to catch native
// signals on the general assumption that they are fatal errors. The bkpt
// instruction appears to cause SIGBUS which is trapped by debuggerd, and
// we've had great difficulty continuing in a debugger once we stop from
// SIG triggered by native code.
//
// Use GDB to set |go| to 1 to resume execution.
#define DEBUG_BREAK() do { \
if (!BeingDebugged()) { \
#include <boost/bind.hpp>
#include <boost/thread.hpp>
class X {
public:
void run();
void complexOperation( int limit );
};
int main()