Skip to content

Instantly share code, notes, and snippets.

View OHIHIYA20's full-sized avatar
🎯
Focusing

Rizal Ohihiya OHIHIYA20

🎯
Focusing
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Threading;
using Timer = System.Windows.Forms.Timer;
using System.IO;
@OHIHIYA20
OHIHIYA20 / ExtFibIteration.cs
Last active December 30, 2019 07:37
C# iterates the data using the Fibonacci sequence
using System.Collections.Generic;
using System.Linq;
public static class ExtFibIteration
{
private static int __fib_step(int current, ref int last)
{
int result = current + last;
last = current;
return result;

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@OHIHIYA20
OHIHIYA20 / gist:e21b8ec2e4907d6e708ec3ee36a6a88c
Created July 26, 2019 02:31 — forked from darkfall/gist:1656050
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
class PngIconConverter
{
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
{
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
{
int width, height;
@OHIHIYA20
OHIHIYA20 / OptimizeForWeb.jsx
Created June 2, 2019 03:04 — forked from livingston/OptimizeForWeb.jsx
Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Written by: Livingston Samuel
// Version 1.0.0
// Required Adobe Photoshop CS 2 and above
//Enable double clicking on Mac Finder & Windows Explorer
#target Photoshop
//Bring app to front
app.bringToFront()
@OHIHIYA20
OHIHIYA20 / gist:621996f73f50cb064e840eb4f39502b4
Created May 2, 2019 03:59 — forked from tylerchesley/gist:6198074
Function to recursively copy files from an Android asset directory
public void copyFileOrDir(String path) {
AssetManager assetManager = this.getAssets();
String assets[] = null;
try {
assets = assetManager.list(path);
if (assets.length == 0) {
copyFile(path);
} else {
String fullPath = "/data/data/" + this.getPackageName() + "/" + path;
File dir = new File(fullPath);
@OHIHIYA20
OHIHIYA20 / Readme.md
Created April 25, 2019 13:34 — forked from HenKun/Readme.md
MarkupExtension for Xamarin.Forms to have simple XAML inline converter

This is a simple MarkupExtension for Xamarin.Forms that imitates an if-else-statement. It was inspired by Thomas Levesque on https://stackoverflow.com/a/841894/6884587

Usage:

  1. Include xmlns:ext="clr-namespace:Xamarin.Forms.Extensions"
  2. Use on a bindable property: <Label Text="{ext:SwitchBinding IsLoggedIn, True=Log out, False=Log in}" />

You can also add a StringFormat:

@OHIHIYA20
OHIHIYA20 / convertGeoToPixel.php
Created March 6, 2019 07:03 — forked from davidlevy/convertGeoToPixel.php
Function to convert Geo coordinates To Pixels
<?php
function convertGeoToPixel($lat, $lon){
$mapWidth = 400;
$mapHeight = 260;
$mapLonLeft = -180;
$mapLonRight = 180;
$mapLonDelta = $mapLonRight - $mapLonLeft;