Skip to content

Instantly share code, notes, and snippets.

@avew
avew / person.json
Last active December 5, 2019 18:53
[
{
"id": "5de95216bd267037d1ef9026",
"image": "https://api.androidhive.info/json/images/tom_hardy.jpg",
"age": 40,
"name": "Ronda Perkins",
"gender": "female",
"company": "CORPULSE",
"email": "rondaperkins@corpulse.com",
"phone": "+62 (888) 528-2396",
@avew
avew / Laravel PHP7 LEMP AWS.md
Created April 27, 2017 11:16 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@avew
avew / nginxproxy.md
Created March 16, 2016 04:22 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

package com.escalata.eventapp.activity.event;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
@avew
avew / jf-menu.js
Last active August 29, 2015 14:17 — forked from JawsomeJason/jf-menu.js
/* Angular directive for enabling a expandable/collapsible hover dropdown menu
* May seem like a lot of code just for a dropdown, but normally, dropdowns
* don't play nice on touch devices, because onmouseleave is not fired unless
* the user touches another element that is clickable or focusable, such as
* a link. This ensures that any touch outside the menu will be considered
* the same as a mouseleave
*
* example menu:
* <nav>
* <ul class="menu" x-jf-menu x-ng-onmouseenter="open()" x-ng-onmouseleave="close()">
@avew
avew / DropDownModelLaravel
Created December 18, 2014 09:45
Create elements for dropdown in model
#Add in your model
class Example extends Eloquent{
public function scopeDropdown()
{
return $this->lists('title','id');
}
}
#Add in your controller
@avew
avew / isInternetOn
Created November 21, 2014 06:38
Cek internet Koneksi Android
public final boolean isInternetOn() {
// get Connectivity Manager object to check connection
ConnectivityManager connec =
(ConnectivityManager) getSystemService(getBaseContext().CONNECTIVITY_SERVICE);
// Check for network connections
if (connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
@avew
avew / gist:6101418
Last active December 20, 2015 08:38
<?php echo '<pre>'; print_r($question); echo '</pre>';?> <br>
<?php foreach ($question as $q): ?>
id :<?php echo $q['id']; ?> <br>
exam _id : <?php echo $q['exam_id']; ?> <br>
question_text :<?php echo $q['question_text']; ?> <br>
review_text :<?php echo $q['review_text']; ?><br>
question_type_id :<?php echo $q['question_type_id']; ?><br>
answer_text :<?php
$answer = $q['answer_text'];
Array
(
[0] => Array
(
[id] => 94
[exam_id] => 24
[question_text] => Toko buku itu mengadakan diskon besar-besaran.
Makna kata yang bercetak miring dalam kalimat di atas adalah...
[review_text] => Makna kata
[question_type_id] => 1
@avew
avew / trigger created_at updated
Created July 2, 2013 12:14
Mysql trigger created_at and updated_at
ALTER TABLE xxxxxx
ADD created_at TIMESTAMP DEFAULT '0000-00-00 00:00:00',
ADD updated_at TIMESTAMP DEFAULT '0000-00-00 00:00:00';
CREATE TRIGGER xxxxxx_create BEFORE INSERT ON `xxxxxx`
FOR EACH ROW SET NEW.created_at = NOW(), NEW.updated_at = NOW();
CREATE TRIGGER xxxxxx_update BEFORE UPDATE ON `xxxxxx`
FOR EACH ROW SET NEW.updated_at = NOW(), NEW.created_at = OLD.created_at;