So here I am on a Sunday, trying to make progress with a personal Laravel 5 site I need to work on. As I bear with the noise outside in the street (some crazy neighbors set up a swimming pool IN THE STREET! :oops:), I’m trying to figure out how too create a new Laravel […]
Coding
Android Development: Permission denied when running ./gradlew in Mac
I’m using a Mac at the moment to work on my Android app projects. For some reason I need to run ./gradlew in the terminal, but I was getting this error: -bash: ./gradlew: Permission denied To fix this, what I did was run the following commands:
1 2 |
Mac-mini:projname moi$ chmod +x gradlew Mac-mini:projname moi$ ./gradlew |
After those commands, my Mac downloaded numerous files […]
Android Studio and the 64K methods limit (DEX error)
Hi! I’ll share a few tips with you on how to find out the number of methods that your Android app has. I’m gonna show you a few tools such as APK file methods counter, and an Android plugin that will show you the number of methods each imported class or dependency has. These will […]
CSS / JavaScript: Twitter Bootstrap center modal vertically on mobile web view
I’ve been working with modal boxes using Twitter Bootstrap. And the page I’m working on needs to be viewed in mobile devices. The modal looks nice and centered when viewed on desktop, but when run in mobile web browsers, it’s aligned to the top. Someone on StackOverflow suggested the use of a helper div plus […]
JavaScript: Get current function name
getCallingFunctionName() is the important function here.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function getCallingFunctionName() { var re = /function (.*?)\(/ var s = getFunctionName.caller.toString(); var m = re.exec( s ) return m[1]; } function myCurrentFunction(){ var func_name = getCallingFunctionName(); alert(func_name); //displays "myCurrentFunction" } myCurrentFunction(); |
Source: Can I get the name of the currently running function in JavaScript?
Android: Switch into another activity
To switch into another activity, the method we use is startActivity(). This is what starts another Android activity:
1 2 |
Intent i = new Intent(this, NameOfActivity.class); startActivity(i); |
Replace NameOfActivity with the name of any activity you’d like to switch into.
Android: Basic WebView Tutorial
A WebView lets you pull a web page and display it in your Android app. It doesn’t take long to implement an Android WebView. Read on. I’ll show you how. AndroidManifest.xml First, open your manifest file to add this permission for INTERNET:
1 |
<uses-permission android:name="android.permission.INTERNET" /> |
The web page won’t be loaded into your app without this permission. […]
PHP dynamic variable names tutorial
I think it’s very convenient for us developers, being able to name our variables dynamically. I’ll show you how to do it in PHP. 🙂 For example, we have variable $foo with “bar” as value like this:
1 2 |
<?php $foo = "bar"; |
If we want to create a variable named based on the “value” of variable $foo, this is […]
PHP: get full URL of current page with GET params or without
The following string variable’s value will get the full URL of the current page, including GET arguments/params, if present.
1 2 3 4 5 6 |
<?php $full_current_url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; echo $full_current_url; ?> |
To get the full URL of current page but WITHOUT the GET args/params, do this instead:
1 2 3 4 5 6 |
<?php $full_current_url = "http://" . strtok($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], "?"); echo $full_current_url; ?> |
The strtok function will return only the part of the URL string up to the character before question […]
PHP: avoid backslash on json_encode
Hey! 🙂 If you are encoding your Arrays to JSON in PHP using json_encode() and the function adds backslash before your slashes, I’m gonna show you a quick fix. This is my original code:
1 2 3 4 5 6 |
<?php $arr = array(); $arr['success'] = true; $arr['message'] = "Please enter email/phone number."; echo json_encode($arr); ?> |
And the result is: {“success”:true,”message”:”Please enter email\/phone number.”} See the added backslash before the slash? Ugly, right? To avoid that, […]