Skip to content

Instantly share code, notes, and snippets.

View AmirHossein's full-sized avatar
🦸‍♂️
Back to the game!

Amir Hossein AmirHossein

🦸‍♂️
Back to the game!
View GitHub Profile
@AmirHossein
AmirHossein / UITextViewWithPlaceholder.swift
Last active August 25, 2020 13:19
Add Placeholder to UITextView
class UITextViewWithPlaceholder: UITextView, UITextViewDelegate {
private var placeholderLabel: UILabel?;
required init?(coder: NSCoder){
super.init(coder: coder)
self.delegate = self;
}
func setPlaceholder(text: String, color: UIColor = Constants.View.whiteColor.withAlphaComponent(0.5)) {
if (self.placeholderLabel == nil) {
@AmirHossein
AmirHossein / CodeGenMeta.java
Created April 19, 2018 12:20 — forked from chrisvest/CodeGenMeta.java
Example showing how to generate, compile, load and run Java programs at run-time.
import javax.tools.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@AmirHossein
AmirHossein / coordinatestoname.js
Last active December 25, 2023 11:15
Get City and Country name by coordinates via Google Maps api
// Demo: http://jsfiddle.net/xuyp8qb5/
// Note: You need Google Map API Key to run demo; bit.ly/2pBgToW
var latlng;
latlng = new google.maps.LatLng(40.730885, -73.997383); // New York, US
//latlng = new google.maps.LatLng(37.990849233935194, 23.738339349999933); // Athens, GR
//latlng = new google.maps.LatLng(48.8567, 2.3508); // Paris, FR
//latlng = new google.maps.LatLng(47.98247572667902, -102.49018710000001); // New Town, US
//latlng = new google.maps.LatLng(35.44448406385493, 50.99001635390618); // Parand, Tehran, IR
//latlng = new google.maps.LatLng(34.66431108560504, 50.89113940078118); // Saveh, Markazi, IR
@AmirHossein
AmirHossein / call_string_functions
Created January 29, 2013 13:52
Call string functions in MooTools
String.implement({
attempt: function() {
var parts = this.split('.'), len = parts.length;
var func = window, bind;
for (var i=0; i<len; i++) {
if (func.hasOwnProperty(parts[i])) {
bind = func;
func = func[parts[i]];
}
}