Skip to content

Instantly share code, notes, and snippets.

View bagaswidodo's full-sized avatar

Bagas Widodo bagaswidodo

  • Corporate, Tbk
  • Greater Jakarta, Indonesia
View GitHub Profile
<?php
if (!empty($_GET['location'])){
/**
* Here we build the url we'll be using to access the google maps api
*/
$maps_url = 'https://'.
'maps.googleapis.com/'.
'maps/api/geocode/json'.
'?address=' . urlencode($_GET['location']);
$maps_json = file_get_contents($maps_url);
<style type="text/css">
.typed-cursor{
opacity: 1;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
@keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
<?php
//Get the q parameter from URL
$q=$_GET["q"];
$hint="";
$link = mysql_connect('pcmu-seb99', 'Support5000', 'bob');
if (!$link)
{
die('Could not connect: '.mysql_error());
}
var startTime = "05:01:20";
var endTime = "09:00:00";
var regExp = /(\d{1,2})\:(\d{1,2})\:(\d{1,2})/;
if(parseInt(endTime .replace(regExp, "$1$2$3")) > parseInt(startTime .replace(regExp, "$1$2$3"))){
alert("End time is greater");
}
@bagaswidodo
bagaswidodo / snippet-1
Created November 17, 2015 04:05
Checkbox binding Laravel
Works fine for me, here's a test I just did here:
Route::get('test', function() {
$user = User::where('email','myemail@domain.com')->first();
Form::model($user);
$user->notify_rate = true;
echo e(Form::checkbox('notify_rate'));
@bagaswidodo
bagaswidodo / autocomplete.js
Last active July 7, 2021 01:46
Autocomplete Laravel
This example definitely worked for me.
// Javascript
<script type="text/javascript">
$(function(){
$("#auto").keyup(function(){
$("#auto").autocomplete({
source:"{{URL('getdata')}}",
minLength: 3
You can use the microtime function for this. From the documentation:
microtime — Return current Unix timestamp with microseconds
Example usage:
$start = microtime(true);
while (...) {
}
$time_elapsed_secs = microtime(true) - $start;
allData.getJson().then(function(json) {
// success, do something with the json
}, function(reason) { // failure, .getJson() had some kind of error
alert('Sorry, unable to retrieve data from the server.')
console.error(reason);
});
var monitorControllers = angular.module('monitorControllers', []);
monitorControllers.controller('MonitorCtrl', function($scope, $http){
$http.get('data/messages.json').success(function(data, status) {
$scope.status = status;
$scope.messages = data;
}).error(function(data, status) {
$scope.messages = data || "Request failed";
$scope.status = status;
@bagaswidodo
bagaswidodo / How To
Created November 30, 2015 14:26
Excel Format
To use this function, create a conversion formula, as in the following example:
#Start Excel and press ALT+F11 to start the Visual Basic Editor.
#On the Insert menu, click Module.
#Enter the sample code for the Convert_Decimal custom function described above into the module sheet.
#Press ALT+F11 to return to excel.
#In cell A1 type the following formula:
=Convert_Decimal("10° 27' 36""")
or
=Convert_Degree(A1)