Skip to content

Instantly share code, notes, and snippets.

View prayogateguh's full-sized avatar
🏠
Working from home

Prayoga Teguh prayogateguh

🏠
Working from home
View GitHub Profile
// Start auto scroll
scroll=window.setInterval(function(){window.scrollTo(0,document.body.scrollHeight);},1000);
// Stop auto scroll
clearInterval(your_number_here);
// Stop all interval
function clearAllIntervals() {
for (var i = 1; i < 99999; i++)
window.clearInterval(i);
@prayogateguh
prayogateguh / download-yt.txt
Created August 6, 2022 10:11
Download YouTube video
# Download YouTube playlist
yt-dlp -f "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b" https://www.youtube.com/playlist?list=PL8gC7LBaclGRz6hq5QlkAa-8icPnvB3mV
List <Apexlog> loglist = [Select Id from Apexlog limit 100];
for(Apexlog al: loglist){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(Url.getOrgDomainUrl().toExternalForm()
+ '/services/data/v44.0/sobjects/Apexlog/'+al.Id);
req.setMethod('DELETE');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
HttpResponse res = h.send(req);
System.debug(res.getStatusCode());
TimeZone tz = UserInfo.getTimeZone();
DateTime dt = Datetime.now();
system.debug('Actual Time as String ' + dt.format());
system.debug('Offset ' + tz.getOffset(dt)/1000);
system.debug('Formatted Time ' + dt.addSeconds((tz.getOffset(dt)/1000)));
@prayogateguh
prayogateguh / Apex.apex
Created December 13, 2021 14:23
Apex snapshots
Winter' 21:
- Safe Navigation Operator:
contactsByBadgeId.get(badBadgeId)?.FirstName;
@isTest
private class Permissions_Tests {
@testSetup
static void testSetup() {
Account a = TestFactory.getAccount('No view for you', true);
Private_Object__c po = new Private_Object__c(Account__c = a.Id, Notes__c = 'Foo');
insert po;
}
@isTest
// download yt cover
youtube-dl --write-thumbnail --skip-download -v https://www.youtube.com/c/Username
@prayogateguh
prayogateguh / youtube-dl.txt
Created August 25, 2020 01:40
YouTube download command line
// download best mp4 video from YouTube
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
##### install node js #####
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh
bash install_nvm.sh
source ~/.profile
nvm ls-remote
nvm install 8.11.1
nvm use 8.11.1
@prayogateguh
prayogateguh / python_code.py
Created July 12, 2020 09:01
all python code will be saved here
def get_signature(path, verb, token, timestamp, body=""):
"""
generate SHA256-HMAC python
"""
token = f"Bearer {token}"
CONSUMER_SECRET = "cY69Vx8dTPbLqTKW"
message = f"path={path}&verb={verb}&token={token}&timestamp={timestamp}&body={body}"
print(message)
message = bytes(message, "utf-8")