Skip to content

Instantly share code, notes, and snippets.

View kadnan's full-sized avatar
📢
Working from home

Adnan Siddiqi kadnan

📢
Working from home
View GitHub Profile
@avelican
avelican / yt-txt.py
Created April 30, 2023 08:19
Get YouTube transcript (from subtitles / caption file)
import sys
import subprocess
if len(sys.argv) < 2:
print("Please provide a YouTube video URL as the first argument.")
sys.exit(1)
video_url = sys.argv[1]
command = [
@veuncent
veuncent / youtube_analytics_oauth.md
Last active July 12, 2023 18:53
Authentication for Google / YouTube Analytics using a Brand Account

Google / YouTube Authentication using a Brand Account

Below describes the only way I was able to get (programmatic) access to the YouTube Analytics API on behalf of our Brand Account. Google documentation is convoluted, to say the least, so if you know a more straightforward way, please do share.

Getting a Client ID and Refresh Token

  1. Create a Project in the Developers Console - https://console.developers.google.com/
  2. Go to the Library tab and enable desired APIs (e.g. YouTube Analytics)
  3. Go to OAuth consent screen and make project external. Select Test mode
@kangchihlun
kangchihlun / usdt_erc20_transfer_demo.js
Last active October 25, 2023 11:21
usdt(erc20) transfer demo
// Created by Chih.Lun.Kang
// 網路上找的範例大部分都不能用,後來嘗試數次只有這方法可行
// 主網的appid => 539ab33xxxx,要去Infura申請,在上面建立一個project
// #### NOTE #### : 要特別注意本身轉帳的帳號要儲備足夠數量的 eth 跟 btc
// #### 注意 #### : 目前使用人工轉換儲值手續費,建議在幣價好的時候一次換匯才划算
const USDTJSON = require('./build/contracts/USDT.json')
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 10, 2024 20:23
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@dylanmckay
dylanmckay / facebook-contact-info-summary.rb
Last active March 12, 2024 22:46
A Ruby script for collecting phone record statistics from a Facebook user data dump
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
#
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
#
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
@Shourai
Shourai / namecheap SSL.md
Created October 21, 2017 12:49
Letsencrypt SSL certificate with namecheap hosting

source: https://savedlog.com/uncategorized/letsencrypt-ssl-certificate-namecheap-hosting/

The “Positive SSL” certificate I bought along with my domain is invalid with any of my subdomains and cannot be used with wildcards. One annoying thing is that namecheap doesn’t offer auto installation of free let’s encrypt certificates, even though, they are saying “Namecheap is dedicated to data security and privacy for all internet users. We believe the movement to encrypt nearly all web traffic is a positive direction. As more sites embrace HTTPS and use of security products, providers of free SSL are beginning to come online.”

Let me show you what it needs to be done in order to “encrypt nearly all web traffic”.

First, not required but it’s helpful to enable ssh access, it is not enabled by default on the base hosting plans, just go an start a live chat and request ssh access.

@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@stidges
stidges / example.php
Created December 19, 2016 12:17
Using when() in the Laravel query builder
<?php
namespace App\Http\Controllers;
use App\Post;
use Illuminate\Http\Request;
class PostsController extends Controller
{
public function index(Request $request)
@pingf
pingf / btree.py
Created November 24, 2016 03:26 — forked from teepark/btree.py
a pure-python B tree and B+ tree implementation
import bisect
import itertools
import operator
class _BNode(object):
__slots__ = ["tree", "contents", "children"]
def __init__(self, tree, contents=None, children=None):
self.tree = tree
@diegopacheco
diegopacheco / elasticsearch-es-delete-all-data.md
Created August 10, 2016 21:36
How to Delete All Data in Elasticsearch?
curl -XDELETE localhost:9200/*