Skip to content

Instantly share code, notes, and snippets.

@devyfriend
devyfriend / misc.txt
Last active December 21, 2015 14:59
Misc codes
/****
yahoo weather for 5 days ahead
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20WHERE%20woeid=%221047378%22%20and%20u=%22c%22&format=json
http://l.yimg.com/a/i/us/we/52/32.gif // 32 = weather code
****/
@devyfriend
devyfriend / MY_Session
Created October 2, 2013 16:17
Custom CI Session library to detect user_id this file only extend and modified sess_update and sess_write function note: must add "user_id" field to ci_session table
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Session extends CI_Session {
public function __construct($params = array())
{
parent::__construct($params);
}
function sess_write()
@devyfriend
devyfriend / fb_detect_app.js
Created December 18, 2013 10:05
dont forget to replace url :)
var IS_ADMIN = '';
document.base_url = 'http://bloodbook.digiatlb.com/';
document.site_url = 'http://bloodbook.digiatlb.com/';
document.scripts_url = 'http://bloodbook.digiatlb.com/scripts/';
document.styles_url = 'http://bloodbook.digiatlb.com/styles/';
document.uploads_url = 'http://bloodbook.digiatlb.com/uploads/';
document.FB_APP_ID = '185057928349987';
document.FB_PAGE_NAME = 'palangmerah';
document.FB_PAGE_ID = '214889140098';
@devyfriend
devyfriend / streamp3
Last active September 3, 2020 22:33
php stream mp3
<?php
$file_name = 'ilu.mp3';
$extension = "mp3";
$mime_type = "audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3";
if(file_exists($file_name)){
header('Content-type: {$mime_type}');
header('Content-length: ' . filesize($file_name));
header('Content-Disposition: filename="' . $file_name);
header('X-Pad: avoid browser bug');
//wrap code in a closure to allow use of $
(function ($) {
AKQA.DeviceManager = (function () {
// Device detection
var isiPad = (navigator.platform.match(/iPad/i)) ? true : false,
isiPod = (navigator.platform.match(/iPod/i)) ? true : false,
isiPhone = (navigator.platform.match(/iPhone/i)) ? true : false,
isAndroid = (navigator.userAgent.match(/Android/i)) ? true : false,
isHandset = isiPhone || isiPod || isAndroid,
<IfModule mod_deflate.c>
# force deflate for mangled headers
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
@devyfriend
devyfriend / ci_table_field_metadata
Created October 14, 2014 11:07
codeigniter read table and field metadata
function readDB()
{
$tables = $this->db->list_tables();
foreach($tables as $table){
$query = $this->db->field_data($table);
echo '<h5>'.$table.'</h5>';
echo '<ul>';
foreach ($query as $field)
{
echo '<li>'.$field->name.' - '.$field->type.' '.($field->primary_key ? '- <b>primary</b>':''). '</li>';
@devyfriend
devyfriend / designer.html
Created October 18, 2014 21:46
designer
<link rel="import" href="../cool-clock/cool-clock.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@devyfriend
devyfriend / mysql_addon
Last active August 29, 2015 14:17
CodeIgniter MySQL "on duplicate key update"
source: http://web.archive.org/web/20090221091226/http://codeigniter.com/forums/viewthread/80958/
add function to two files
1st file: /system/database/drivers/mysql/mysql_driver.php and perhaps file mysqli_driver.php too
/**
* ON DUPLICATE UPDATE statement
*
* Generates a platform-specific on duplicate key update string from the supplied data
*
@devyfriend
devyfriend / localdate_helper
Last active August 29, 2015 14:17
ci_helper tanggalan lokal
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('tgl_indo'))
{
function tgl_indo($tgl)
{
$ubah = gmdate($tgl, time()+60*60*8);
$pecah = explode("-",$ubah);
$tanggal = $pecah[2];
$bulan = bulan($pecah[1]);