Skip to content

Instantly share code, notes, and snippets.

@devyfriend
devyfriend / terbilang_helper
Created March 28, 2015 20:27
ci_helper terbilang
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Terbilang Helper
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author Gede Lumbung
* @link http://gedelumbung.com
@media (min-width: 768px) {}
@media (min-width: 992px) {}
@media (min-width: 1200px) {}
@media screen and (max-width: 767px) {}
@media screen and (min-width: 768px) {}
@media screen and (-webkit-min-device-pixel-ratio: 0) {}
@media (max-device-width: 480px) and (orientation: landscape) {}
@media (max-width: 767px) {}
@media all and (transform-3d), (-webkit-transform-3d) {}
@media (min-width: 768px) and (max-width: 991px) {}
@devyfriend
devyfriend / navi-onhover.html
Last active July 13, 2016 09:31
popup dropdown navi with modal background
<!DOCTYPE html>
<html>
<head>
<style>
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
@devyfriend
devyfriend / index.html
Last active July 16, 2016 23:25
CSS "Always on the bottom" Footer
<style>
/**
* Demo Styles
*/
html {
height: 100%; /* <-- this is it --> */
box-sizing: border-box;
}
@devyfriend
devyfriend / tglsekarang.js
Created August 2, 2016 19:54
tanggal sekarang dengan format indonesia
jQuery(document).ready(function($){
function getTime(){
var text="";
var d=new Date();
var days=['Minggu','Senin','Selasa','Rabu','Kamis','Jum\'at','Sabtu'];
text +=days[d.getDay()];
var tanggal=d.getDate();
text +=', '+tanggal;
var bulan=['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli','Agustus', 'September', 'Oktober', 'Nopember', 'Desember'];
text +=' '+bulan[d.getMonth()];
@devyfriend
devyfriend / randomcolor_php_js.txt
Created February 6, 2017 08:24
generate random color in php and pastel color in javascript
<?php
function random_color_1(){
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
return '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
}
function random_color_3(){
return '#'.strtoupper(dechex(rand(0,10000000)));
}
function random_color_2(){
$spread = 25;
@devyfriend
devyfriend / .htaccess
Created February 12, 2017 08:33
htaccess to force to https
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
@devyfriend
devyfriend / vue-quill.js
Created May 16, 2017 10:28
vue + quilljs + image resize
<template lang="html">
<div id="editor">
<quill-editor
class="editor-example"
ref="myQuillEditor"
:content="content"
:options="editorOption"
@change="onEditorChange($event)">
</quill-editor>
</div>
@devyfriend
devyfriend / valid.txt
Created July 17, 2017 06:57
validation
SELECT * FROM `table` WHERE email REGEXP '^[A-Za-z0-9._%\-+!#$&/=?^|~]+@[A-Za-z0-9.-]+[.][A-Za-z]+$';
@devyfriend
devyfriend / post_image.php
Last active October 12, 2017 13:58
wordpress get post image
function post_image_first($post){
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if(isset($matches[1][0])){
$first_img = $matches[1][0];
if(empty($first_img)){
//Defines a default image
$first_img = false;