Skip to content

Instantly share code, notes, and snippets.

@cojahmetov
cojahmetov / getqutes.php
Created May 11, 2020 05:25 — forked from purwantoid/getqutes.php
Google Finance API
public function getQuetesv2($ticker)
{
$infoUrl='https://finance.google.com/finance?q=idx:'.$ticker.'&output=json';
$contents = str_replace('//','',file_get_contents($infoUrl));
$json = json_decode($contents, true);
if(!array_key_exists("results_type",$json)){
$data=$json[0];
@cojahmetov
cojahmetov / is_number.js
Last active October 31, 2016 01:12
#js# check if number
function isNumeric(n)
{
var n2 = n;
n = parseFloat(n);
return (n!='NaN' && n2==n);
}
if (! $.isNumeric(unit_price))
{
// do something
@cojahmetov
cojahmetov / where_is_the_problem.js
Created May 28, 2015 18:21
#js# where is the issue
function getItemByItemVal(obj, itemName, itemVal)
{
var retObj = {};
for (var k in obj)
{
if (obj.hasOwnProperty(k))
{
var item = obj[k];
if (item.hasOwnProperty(itemName) && item[itemName] == itemVal) {
@cojahmetov
cojahmetov / object_keys.js
Created April 6, 2015 18:20
#js# get the object keys list
function getKeys(obj) {
var r = []
for (var k in obj) {
if (!obj.hasOwnProperty(k))
continue
r.push(k)
}
return r
}
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@cojahmetov
cojahmetov / controller.php
Created March 12, 2015 21:38
#laravel# Pagination with Ajax ver.2
<?php
// controller
public function getDetails($id)
{
//Retrieve post details
$data["post"] = Blog::post_details($id);
//Retrieve comments for this post
$data["comments"] = $comments = Blog::post_comments($id,4);
@cojahmetov
cojahmetov / BlogController.php
Last active August 29, 2015 14:16 — forked from tobysteward/BlogController.php
#laravel# Pagination with Ajax
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@cojahmetov
cojahmetov / remove_style.js
Last active August 29, 2015 14:15
#jquery# remove style added with .css() function
$.fn.removeCss=function(all){
if(all===true){
$(this).removeAttr('class');
}
return $(this).removeAttr('style')
}
//For your case ,Use it as following :
$(<mySelector>).removeCss();
@cojahmetov
cojahmetov / to_plain_text.js
Created February 5, 2015 19:56
#js# Convert html to plain text
//Converter HTML to plain text like Gmail:
html = html.replace(/<style([\s\S]*?)<\/style>/gi, '');
html = html.replace(/<script([\s\S]*?)<\/script>/gi, '');
html = html.replace(/<\/div>/ig, '\n');
html = html.replace(/<\/li>/ig, '\n');
html = html.replace(/<li>/ig, ' * ');
html = html.replace(/<\/ul>/ig, '\n');
@cojahmetov
cojahmetov / toHtml.js
Created February 5, 2015 19:52
#js# content to html entities
function htmlEntities (str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
function toHtml(content) {