Skip to content

Instantly share code, notes, and snippets.

View ashumeow's full-sized avatar
🎯
Moving Forward

Aswini S ashumeow

🎯
Moving Forward
View GitHub Profile
@ashumeow
ashumeow / plusone.js
Last active November 23, 2023 04:33 — forked from shuhblam/plusone.js
// unminifed version of https://apis.google.com/js/plusone.js
// see https://developers.google.com/+/plugins/+1button/#getting-started
window.___jsl = window.___jsl || {};
window.___jsl.h = window.___jsl.h || 'm;\/_\/apps-static\/_\/js\/gapi\/__features__\/rt=j\/ver=zVTxVnVbJog.en_US.\/sv=1\/am=!FRwcaGMpC1CIJ0aI4g\/d=1\/';
window.___jsl.l = [];
window.___gpq = [];
window.gapi = window.gapi || {};
window.gapi.plusone = window.gapi.plusone || (function () {
function f(n) {
@ashumeow
ashumeow / kthElement.php
Created July 12, 2023 09:31
codechef problem
<?php
// problem
// Alice adds the numbers to list in the following order
// [1,4,7,10,2,5,8,3,6,9]
// The 7th number in the list is 8
// solution
$b=[1,4,7,10,2,5,8,3,6,9];
@ashumeow
ashumeow / create_file_Qt
Created May 16, 2018 03:10 — forked from diniremix/create_file_Qt
create file of text in Qt
void MainWindow::createfile(){
QString filename="test.txt";
QFile file(filename);
if(!file.exists()){
qDebug() << "NO existe el archivo "<<filename;
}else{
qDebug() << filename<<" encontrado...";
}
QString mesg="una segunda linea";
if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
@ashumeow
ashumeow / currency.php
Last active January 9, 2018 13:23 — forked from dcblogdev/gist:8067095
Use Google finance calculator to convert currency with php
<?php
function convertCurrency($amount, $from, $to){
$data = file_get_contents("https://finance.google.com/finance/converter?a=$amount&from=$from&to=$to");
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return number_format(round($converted, 3),2);
}
echo convertCurrency("10.00", "AED", "USD");
?>
@ashumeow
ashumeow / script.php
Last active March 30, 2016 10:39
Connecting to MySQL database via PHP script
<?php
$host = '127.0.0.1';
$user = 'abc';
$pwd = 'abc';
$db = 'xyz';
$con = mysql_connect($host, $user, $pwd) or die("connection failed");
mysql_select_db($db,$con) or die("db selection failed");
@ashumeow
ashumeow / PrimeCheck
Last active January 4, 2016 15:09 — forked from freemo/PrimeCheck.hs
function (isPrime(number))
{
if ((number == 2) || (number == 3))
return true;
if ((number % 2 === 0) || (number % 3 === 0))
return false;
var maxDivisor = Math.sqrt(number);
var dividendIndex = 1;
var dividend = 5;
class intmult
{
public:
virtual intmult(int a,int b)=0;
};
class Multiply:public intmult
{
public:
virtual intmult(int a,int b)
{
@ashumeow
ashumeow / http.rb
Created November 15, 2013 23:01
Sample Gist. (^_^)
require 'open-uri'
kittens = open('http://placekitten.com/')
response_status = kittens.status
response_body = kittens.read[559, 441]
puts response_status
puts response_body
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.dragonwolverines.com/", false);
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);
var my_canvas = document.getElementById("canvas");
var context = my_canvas.getContext("2d");
context.beginPath();
context.arc(75,75,35,0,2*Math.PI);
context.fillStyle = "red";
context.fillRect(10, 10, 50, 20);
context.font = "30px Garamond";
context.fillText("Hello!",15,175);
context.stroke();