Skip to content

Instantly share code, notes, and snippets.

View tingplenting's full-sized avatar

Kar tingplenting

  • tingplenting.github.io
  • Yogyakarta, Indonesia
View GitHub Profile
<input class="checkit" type="checkbox" name="daftar" value="Bike"> I have a bike<br>
<input class="checkit" type="checkbox" name="daftar" value="Car" checked> I have a car<br>
<input class="checkit" type="checkbox" name="daftar" value="Pen" checked> I have a Pen<br>
<input type="button" onclick="alert(getCheckedCheckboxesFor('daftar'));" value="Get Values" />
<button id="create">Create file</button>
<a download="info.txt" id="downloadlink" style="display: none">Download</a>
<script>
function getCheckedCheckboxesFor(checkboxName) {
import statistics as _s
# diketahui
A = list(range(1000000))
# 4a
def mean_odd_number(n):
odds = filter(lambda x: x % 2, n)
return _s.mean(odds)
@tingplenting
tingplenting / tatar1000pi.py
Last active October 16, 2018 04:18
menghitung pi seirbu digit setelah koma. taruh jumlah digit di main(1000)
def calcPi(limit): # Generator function
"""
Prints out the digits of PI
until it reaches the given limit
"""
q, r, t, k, n, l = 1, 0, 1, 1, 3, 3
decimal = limit
counter = 0
@tingplenting
tingplenting / ffmpeg_tuts.md
Last active April 18, 2024 17:31
ffmpeg cli for youtube

Extract audio from a YouTube video file

ffmpeg -i INPUT.mp4 -ab 256k OUTPUT.mp3

Cut 3s length

ffmpeg -y -ss 00:00:03 -i INPUT.mp4 -codec copy OUTPUT.mp4
@tingplenting
tingplenting / ffmpeg_convert.py
Created September 18, 2018 07:28
bulk convert with ffmpeg and python
import os
DIRECTORY = "videos2"
for f in os.listdir(DIRECTORY):
if f.endswith(".mp4"):
in_file = DIRECTORY + '/' + f
out_file = DIRECTORY + '/ytout-- ' + f
ex = 'ffmpeg -i "{in_file}" -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low "{out_file}"'.format(in_file=in_file, out_file=out_file)
os.system(ex)
@tingplenting
tingplenting / encode.sh
Created September 18, 2018 02:04 — forked from mikoim/README.md
YouTube recommended encoding settings on ffmpeg (+ libx264)
#/bin/sh
ffmpeg -i input -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low output
@tingplenting
tingplenting / pagination-collection.liquid
Created May 10, 2018 06:42 — forked from Phlow/pagination-collection.liquid
If you need pagination for a collection in a Jekyll theme, you can use the following Liquid logic which works also on Github pages
{% comment %}
#
# I modified the original code from http://anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/
#
# Make a collection in _config.yml and create the folder _your_collection in your root.
#
# collections:
# your_collection:
# output: true
# permalink: /:collection/:title/
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $post_id
* @param Array $meta_data
* @return Int Attachment ID
*/
function crb_insert_attachment_from_url($url, $post_id = null) {
<script type="text/javascript">
$(document).ready(function(){
var count = 10;
var countdown = setInterval(function(){
if (count == 0) {
clearInterval(countdown);
$('#googleads-1').load('http//www.example.com/ads/app/adsense.txt');
$('#googleads-2').load('http//www.example.com/ads/app/adsense.txt');
// adsense.txt contain your adsense code
}
<?php
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div id="googleads-1"></div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );