Skip to content

Instantly share code, notes, and snippets.

@manhtai
manhtai / macos-app-icon.md
Last active January 16, 2023 07:52 — forked from jamieweavis/macos-app-icon.md
How to create an .icns macOS app icon
@manhtai
manhtai / get_audio.py
Created December 6, 2022 07:28
Get audio files from learninglink.oup.com
import requests
import bs4
import os
root = "https://learninglink.oup.com"
url = root + "/access/laitz-4e-student-resources"
def get_page_links():
res = requests.get(url)
@manhtai
manhtai / lambda.py
Created April 25, 2020 14:36
Auto backup Lightsail instance
from __future__ import print_function
import boto3
from datetime import datetime, timedelta
from os import getenv
from sys import stdout
from time import time
DEFAULT_RETENTION_DAYS = 1
AUTO_SNAPSHOT_SUFFIX = 'auto'
@manhtai
manhtai / googleads_ipblock.py
Created August 8, 2019 14:52
googleads python ipblock
from googleads import adwords
CAMPAIGN_ID = 'YOUR_CAMPAIGN_ID'
BLOCK_IP = '1.1.1.1'
def main(client, campaign_id, block_ip):
# Initialize appropriate service.
campaign_criterion_service = client.GetService('CampaignCriterionService',
#!/usr/bin/env python3
def solve(customer, warehouses):
"""
Choose warehoues to take products for customer base on some rules.
Input:
`customer`: Dictionary contains city & product list of a customer
Eg: {"city": "Hanoi", "product": {"book": 1, "pen": 2}}
@manhtai
manhtai / myFunction.js
Created December 31, 2018 09:52
Google app script create new sheet for each row
function myFunction() {
var mainSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses 1');
var data = mainSheet.getDataRange().getValues();
var doneValue = "Done";
for (var i = 0; i < data.length; i++) {
Logger.log(mainSheet.getRange(i+1, 10).getValue());
if (mainSheet.getRange(i+1, 10).getValue() != doneValue) {
var email = data[i][2]; // Assume email is in column 3
@manhtai
manhtai / upgrade-jenkins.sh
Created August 23, 2018 15:53 — forked from cyxou/upgrade-jenkins.sh
Upgrade Jenkins on Bitnami VM
#!/bin/bash
cd /opt/bitnami
sudo ./ctlscript.sh stop
sudo cp -f apache-tomcat/webapps/jenkins.war apps/jenkins/jenkins.war.bak
sudo wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
sudo mv jenkins.war apache-tomcat/webapps/
sudo rm -rf apache-tomcat/work/Catalina/localhost
sudo rm -rf apache-tomcat/webapps/jenkins
sudo ./ctlscript.sh start
@manhtai
manhtai / lambda_function.py
Created May 21, 2018 13:45
Lambda function for draining ECS instances before terminating it
from __future__ import print_function
import boto3
import base64
import json
import logging
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
@manhtai
manhtai / infosec_newbie.md
Created May 13, 2018 03:33 — forked from mubix/infosec_newbie.md
How to start in Infosec

Keybase proof

I hereby claim:

  • I am manhtai on github.
  • I am manhtai (https://keybase.io/manhtai) on keybase.
  • I have a public key ASAGaIx-aeYCP7eija_x4KxghP4CvhKrvvIMACWFJ2npQwo

To claim this, I am signing this object: