Skip to content

Instantly share code, notes, and snippets.

View katopz's full-sized avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@katopz
katopz / gql_query_search_stargazers_fragment.gql
Created November 29, 2016 10:55
GraphQL Github Example : Search for top ten stargazers via query with fragment
// Try at : https://graphql-explorer.githubapp.com/
// With query variables below
// { "queryString": "language:JavaScript stars:>10000" }
query SearchMostTop10Star($queryString: String!) {
search(query: $queryString, type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
..._Repository
@katopz
katopz / gql_query_search_stargazers.gql
Created November 26, 2016 04:55
GraphQL Github Example : Search for top ten stargazers via query
// Try at : https://graphql-explorer.githubapp.com/
// With query variables below
// { "queryString": "language:JavaScript stars:>10000" }
query SearchMostTop10Star($queryString: String!) {
search(query: $queryString, type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
... on Repository {
@katopz
katopz / gql_search_stargazers.gql
Created November 26, 2016 04:54
GraphQL Github Example : Search for top ten stargazers
// Try at : https://graphql-explorer.githubapp.com/
{
search(query: "language:JavaScript stars:>10000", type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
... on Repository {
name
descriptionHTML
stargazers {
@katopz
katopz / console.js
Created November 9, 2016 08:37
Playing with console
// Will print... [2016-11-09T07:52:09.303Z] foo bar
// ES6
var _log = _log || console.log;
console.log = (...arguments) => {
arguments.unshift(`[${new Date().toISOString()}]`)
_log.apply(console, arguments);
};
console.log('foo', 'bar');
// ES5
@katopz
katopz / gist:30a0ae273d0d99617babc3c5c7067120
Created October 3, 2016 14:57
iOS10 Push Notifications registerForRemoteNotifications
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) {
// iOS 10+
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
print("Notifications access granted: \(granted.description)")
}
application.registerForRemoteNotifications()
} else {
// iOS 8, 9
@katopz
katopz / GetRepositoryInfo.gql
Last active July 30, 2022 10:43
GraphQL Github Example : Get repository info.
// Try at : https://graphql-explorer.githubapp.com/
query {
repositoryOwner (login: "facebook") {
repositories {
totalCount
}
repository(name: "react") {
description
forks {
totalCount
@katopz
katopz / GetRepositoryIssues.gql
Last active April 25, 2018 14:02
GraphQL Github Example
// Try at : https://graphql-explorer.githubapp.com/
// With query variables below
// {"name": "react", "login": "facebook", "states": "CLOSED"}
query GetRepositoryIssues($states: [IssueState!], $name: String!, $login: String!) {
repositoryOwner(login: $login) {
repository(name: $name) {
issues(last: 10, states: $states) {
edges {
node {
title
resolve: () => {
return new Promise((resolve, reject) => {
db.collection('todos').find({}).toArray((err, todos) => {
if (err) reject(err)
else resolve(todos)
})
})
}
# Install Docker on Ubuntu 14.04.4 x64
# Ref https://docs.docker.com/engine/installation/linux/ubuntulinux/
# No interactive for now.
export DEBIAN_FRONTEND=noninteractive
# Update your APT package index.
apt-get -y update
# Update package information, ensure that APT works with the https method, and that CA certificates are installed.
apt-get -y install apt-transport-https ca-certificates
# Add the new GPG key.
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
@katopz
katopz / setup.sh
Last active November 29, 2016 13:43
For setup 3 MongoDB replica set in Docker container and use data volume for db. will need https://gist.github.com/katopz/0f553b431302d9313ebfa7d48b53db89
## Setup Docker
NETWORK_NAME=${1:-my-mongo-cluster}
REPLICASET_NAME=${2:-my-mongo-set}
# Disconnect old container if has.
docker network disconnect -f $NETWORK_NAME mongo0
docker network disconnect -f $NETWORK_NAME mongo1
docker network disconnect -f $NETWORK_NAME mongo2
# Remove old network if has.
docker network rm $NETWORK_NAME