Skip to content

Instantly share code, notes, and snippets.

View heitara's full-sized avatar
💻
Swift & SwiftUI

Emil Atanasov heitara

💻
Swift & SwiftUI
View GitHub Profile
//this is jsut the "meat" of the solution
const PEPPERFLASH_PLUGIN = 'resources/pepperFlash/mac/PepperFlashPlayer.plugin'
let pluginName
let pluginDir = __dirname
switch (process.platform) {
case 'win32':
switch (process.arch) {
case "x64":
pluginName = PEPPERFLASH_PLUGIN_WIN64
break;
{
"asarUnpack" : ["resources/pepperFlash/mac"]
}
@heitara
heitara / electron.pepper.flash.index.js
Last active July 31, 2020 23:47
How to load properly PepperFlash in Electron on Mac
//this is jsut the "meat" of the solution
const PEPPERFLASH_PLUGIN = __dirname.indexOf("asar") >=0 ? '../resources/pepperFlash/mac/PepperFlashPlayer.plugin' : 'resources/pepperFlash/mac/PepperFlashPlayer.plugin'
let pluginName
switch (process.platform) {
case 'win32':
switch (process.arch) {
case "x64":
pluginName = PEPPERFLASH_PLUGIN_WIN64
break;
default:
@heitara
heitara / numbertotext-bg.js
Last active June 2, 2020 16:28
Number to text, number to words, Словом, Число в текст на български
let toBGN = (value) => {
let under10 = (value, currency = false) => {
let index = Math.floor(value)
if(index > 10) {
index = 10;
}
let resultArray =
[
"нула", "един", "два", "три", "четири", "пет", "шест",
@heitara
heitara / imagemagick.shell.sh
Created May 3, 2020 07:56
Image Magick resize buch of images
#!/bin/bash
FILES=*.jpg
mkdir out
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
convert $f -resize 2000x2000\> out/$f
done
@heitara
heitara / ImageMagick.Watermark.bat
Created May 3, 2020 07:55
Image Magick resize and manipulate files on Windows
REM add watermark to all JPG images in the same folder
REM resize all JPG images in the same folder
REM put the result in different folder
SET IMAGE_MAGICK="C:\Program Files\ImageMagick-7.0.10-Q16\magick.exe"
SET SIZE=700x700
mkdir watermark
mkdir resize
for /F "usebackq delims=" %%i in (`dir /a:-d /b %foldername%\*.jpg`) do %IMAGE_MAGICK% %%i ( watermark.png ) -gravity center -composite watermark\%%i
@heitara
heitara / BadgeViewUsage.swift
Created February 10, 2020 22:23
Use BadgeContainer Protocol
//custom class
//Don't forget to assigne that custom class to your UIButton views in the storyboard file
class BadgeButton: UIButton, BadgeContainer {
var badgeTimer: Timer?
var badgeView: UIView?
var badgeLabel: UILabel?
}
//here is how to use it in simple view controller
class MyViewController: UIViewController {
@heitara
heitara / BadgeView.swift
Last active February 7, 2020 18:00
Add a Badge View with a Label
// Created by © 2020 SwiftEverywhere. Can be used free of charge.
import UIKit
//protocol
protocol BadgeContainer: class {
var badgeView: UIView? { get set }
var badgeLabel: UILabel? { get set }
func showBadge(blink: Bool, text: String?)
func hideBadge()
}
//default protocol implementation
@heitara
heitara / BadgeContainer.swift
Created February 2, 2020 14:09
Clean Red Badge implementation in Swift
// Created by © 2020 SwiftEverywhere. Can be used free of charge.
import UIKit
//protocol
protocol BadgeContainer: class {
var timer: Timer? { get set }
var badgeView: UIView? { get set }
var label: UILabel? { get set }
func showBadge(blink: Bool, text: String?)
func hideBadge()
}
@heitara
heitara / UIDevice+Extensions.swift
Created October 28, 2019 08:20
Distinguish different iPhones based on the device screen height.
//
// UIDevice+Extensions.swift
// tenbet
//
// Created by Emil Atanasov on 28.10.19.
// Copyright © 2019. All rights reserved.
//
//based on https://stackoverflow.com/questions/46192280/detect-if-the-device-is-iphone-x/47067296