Skip to content

Instantly share code, notes, and snippets.

View alfondotnet's full-sized avatar
🏄‍♂️
🏄 🏄 🏄 🏄 🏄 🏄 🏄

Alfonso Embid-Desmet alfondotnet

🏄‍♂️
🏄 🏄 🏄 🏄 🏄 🏄 🏄
View GitHub Profile
@alfondotnet
alfondotnet / confirmation-react-decorator-poc.js
Created February 5, 2016 19:17
Request Confirmation decorator for React Component methods.
// Full Proof of Concept here http://jsbin.com/hupejawequ/1/edit?html,css,js,output
@requireConfirmation(["pay"]) // only request confirmation for the 'pay' method
class FormWithButton extends React.Component {
constructor() {
super();
// We have to bind, () => {} doesnt work
this.pay = this.pay.bind(this);
this.request = this.request.bind(this);
@alfondotnet
alfondotnet / Discover Yelp Businesses script
Created September 24, 2016 00:04
Discover Yelp Businesses
# -*- encoding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from recommendations.models import *
import httplib, json, urllib2
from optparse import make_option
import yelp_api
# YOUR API DETAILS
consumer_key = 'XXXXX'
consumer_secret = 'XXXXX'
# -*- encoding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from recommendations.models import *
import httplib, json
from optparse import make_option
import re
from random import randrange
from urllib import quote
import time
@alfondotnet
alfondotnet / apollo_error_sample.js
Last active March 21, 2017 00:37
Weird apollo-client's queryObservable's behaviour
import React from "react";
// ....
// Response from server
// {"data":{"entities":{"edges":[{"cursor":"MQ==","node":{"__id":"1","name":"Coke","__typename":"Brand"},"__typename":"BrandEdge"},{"cursor":"Mg==","node":{"__id":"2","name":"Pepsi","__typename":"Brand"},"__typename":"BrandEdge"},{"cursor":"Mw==","node":{"__id":"3","name":"Heinz","__typename":"Brand"},"__typename":"BrandEdge"}],"pageInfo":{"hasNextPage":false,"startCursor":"MQ==","endCursor":"Mw==","__typename":"PageInfo"},"__typename":"BrandConnection"}}}
const filtersQuery = gql`
query ($first: Int, $name: String, $orderDirection: OrderDirection, $orderProperty: BrandOrderProperty) {
entities: brandsConnection(first: $first, name: $name, orderDirection: $orderDirection, orderProperty: $orderProperty) {
edges {
@alfondotnet
alfondotnet / dummy_graphql_client.js
Last active April 17, 2017 18:50
Dummy graphQL client
export function requestUserData({ headers, userId }) {
return fetch(`${API_URL}/graphql/queries`, {
headers: {
...headers,
'Content-Type': 'application/json',
},
method: 'POST',
body: JSON.stringify({
query: `query RequestUserDataQuery ($userId: Int) {
users (id: $userId) {
from datetime import datetime
file = open('/home/user/.chia/mainnet/log/debug.log')
old_timestamp = None
res_by_int_deltas = {}
for l in file:
@alfondotnet
alfondotnet / chia_alerter.py
Last active March 26, 2021 15:47
chia alerter
import requests
import re
import time
import random
import subprocess
MAILGUN_API_KEY = 'API_KEY'
MAILGUN_DOMAIN = 'yourdomain.com'
CHIA_ADDRESS = 'CHIA_ADDRESS'
from datetime import datetime
import re
file = open('/home/fon/.chia/mainnet/log/debug.log')
suffixes = ["", ".1", ".2", ".3", ".4", ".5", ".6", ".7"]
finished_compiled = re.compile(r'Finished signage point (\d+)\/\d+')
for s in suffixes:
#!/bin/bash
# Script by @xorinox in Chia's keybcase
pdp="/chia/plots/disk*"
i=1
for dp in $(/usr/bin/find $pdp -maxdepth 0 -type d); do
id=$(basename $dp)
ret=$(/bin/lsblk |/usr/bin/grep "$dp")
if [ $? -ne 0 ]; then
/usr/sbin/findfs LABEL="$id" &>/dev/null
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><link rel="preconnect" href="https://static.linear.app" crossorigin="anonymous"/><link rel="preconnect" href="https://cdn.sanity.io" crossorigin="anonymous"/><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/><link rel="preload" as="image" href="https://cdn.sanity.io/images/ornj730p/production/dff9dd98ea36ac93a38ef6405abc866dda659f68-492x492.jpg?w=128&amp;h=128&amp;q=95&amp;auto=format&amp;dpr=2"/><link rel="preload" as="image" href="https://cdn.sanity.io/images/ornj730p/production/4d081a7a9ee2575014ab150f2d74cc3e2266a937-300x300.jpg?w=128&amp;h=128&amp;q=95&amp;auto=format&amp;dpr=2"/><link rel="preload" as="image" href="https://cdn.sanity.io/images/ornj730p/production/c5229881e58cfb3a30c31b036e2965f9f327dcc8-512x512.png?w=128&amp;h=128&amp;q=95&amp;auto=format&amp;dpr=2"/><link rel="preload" as="image" href="https://cdn.sanity.io/images/ornj730p/production/2e281ae34028ff175a63af027de95bca66b9bcb1-2056x944.png?