Skip to content

Instantly share code, notes, and snippets.

View afrijaldz's full-sized avatar
:octocat:
Focusing

Afrijal Dzuhri afrijaldz

:octocat:
Focusing
View GitHub Profile
@afrijaldz
afrijaldz / instagram_scrape.php
Created December 16, 2016 18:56 — forked from cosmocatalano/instagram_scrape.php
Quick-and-dirty Instagram web scrape, just in case you don't think you should have to make your users log in to deliver them public photos.
<?php
//returns a big old hunk of JSON from a non-private IG account page.
function scrape_insta($username) {
$insta_source = file_get_contents('http://instagram.com/'.$username);
$shards = explode('window._sharedData = ', $insta_source);
$insta_json = explode(';</script>', $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);
return $insta_array;
}
@afrijaldz
afrijaldz / .htaccess
Created July 13, 2017 14:11
setup htaccess angular without hash ( # )
<IfModule mod_rewrite.c>
RewriteEngine On
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
</IfModule>
@afrijaldz
afrijaldz / component.ts
Created August 15, 2017 09:50
no Internet connection, network detecting angular
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dashboard',
template: `{{ online }}`,
})
export class DashboardComponent implements OnInit {
online = navigator.onLine;
constructor() {
@afrijaldz
afrijaldz / object_for_pipe.ts
Last active August 19, 2017 12:44
object untuk membuat tutorial angular pipe
products = [
{
harga: 549813,
berat: 26
},
{
harga: 522586,
berat: 39
},
{
@afrijaldz
afrijaldz / tampilan_awal_pipe.html
Last active August 19, 2017 12:43
tampilan depan awal membuat angular pipe
<table style="width:100%" border="1">
<tr>
<th>Harga Produk</th>
<th>Jumlah Produk</th>
</tr>
<tr *ngFor="let product of products">
<td>{{ product.harga }}</td>
<td>{{ product.berat }}</td>
</tr>
</table>
@afrijaldz
afrijaldz / pipe_harga.ts
Created August 19, 2017 12:51
pipe untuk menampilkan harga dengan mata uang dan titik
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'harga'
})
export class HargaPipe implements PipeTransform {
transform(value: any): any {
return 'Rp. '+ value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'berat'
})
export class BeratPipe implements PipeTransform {
transform(value: any, ...args: any[]): any {
return value + ' kg';
}
........
import { HargaPipe } from './harga.pipe';
import { BeratPipe } from './berat.pipe';
@NgModule({
declarations: [
.......
HargaPipe,
BeratPipe,
],
<tr *ngFor="let product of products">
<td>{{ product.harga | harga }}</td>
<td>{{ product.berat | berat }}</td>
</tr>
@afrijaldz
afrijaldz / output.json
Created September 10, 2017 09:05
example output data from form angular
{
"fullname": "John Doe",
"address": "Giriwoyo, Wonogiri, Jawa Tengah",
"phone": "0812234345456",
"gender": "male",
"birthdate": "1995-08-04",
"smoking": false,
"interest": ["business", "programming", "life lesson", "future"],
"family": [
{