Skip to content

Instantly share code, notes, and snippets.

@PhanDuc
PhanDuc / gist:cd2111012bf9ca44ea16888abc842258
Last active October 19, 2016 07:22
Hide comment facebook
def hide_comment(webhook_comment_callback):
page_access_token = ""
base = "https://graph.facebook.com/v2.8"
node = "/%s" % webhook_comment_callback['value']['comment_id']
fields = "?is_hidden=true"
parameters = "&access_token=%s" % page_access_token
url = base + node + fields + parameters
print("URL : ", url)
req = urllib.request.Request(url)
success = False
@PhanDuc
PhanDuc / gist:6e36a377c6d649c5f82dd184824a6a0a
Created October 21, 2016 03:38
Error 500 with FB when post comment as guest
Internal Server Error: /fb_webhooks/d1a0311fe8b709a5cb027ae2567a692712fad78702d6b78b5a/
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
response = get_response(request)
File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
improt pandas as pd
pd.set_option("display.width", 320)
@PhanDuc
PhanDuc / infiniteScroll_1.py
Created December 16, 2016 09:08 — forked from artjomb/infiniteScroll_1.py
infinite scroll of stackstatus with python in phantomjs
import selenium
import time
from selenium import webdriver
browser = webdriver.PhantomJS("phantomjs")
browser.get("https://twitter.com/StackStatus")
print browser.title
pause = 3
from bs4 import BeautifulSoup
import requests
import re
import csv
import pickle
id_data_list = []
data_csv = []
csv_columns = ['Name','FB ID']
from bs4 import BeautifulSoup
import requests
import re
import csv
import pickle
from gevent.pool import Pool
id_data_list = []
data_csv = []
'use strict';
const apiai = require('apiai');
const config = require('./config');
const express = require('express');
const crypto = require('crypto');
const bodyParser = require('body-parser');
const request = require('request');
const app = express();
const uuid = require('uuid');
import pandas as pd
df = pd.read_excel('D:\\BILL THÁNG 1.xlsx')
du = df.ix[:, 4]
temp_list = []
for cell in du:
try:
ed = ''.join(cell.split(',')[-1])
print(ed)
temp_list.append(ed)
import numpy as np
import scipy as sp
from numpy import random
from numpy import matlib
import matplotlib.pyplot as plt
from gurobipy import GRB
import gurobipy as grb
class Problem:
def nearest_neighbours(X, Y, norm=2.0):
"""Index the rows of `Y` in increasing order of distance from each row in `X`.
Parameters
----------
X : array, 2 dimensional, shape = (n_samples, n_dim)
The matrix, for the rows of which to find the closest row in `Y`.
Y : array, 2 dimensional, shape = (n_reference, n_dim)
The matrix, among the rows of which to seek the closest one for `X`.