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 / 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 / GalileoSequencer.ino
Last active August 29, 2015 14:27 — forked from X-Y/GalileoSequencer.ino
Galileo Sequencer This sketch is used for a demo of the Intel Galileo board. When it was launched in Rome Maker fair 2013, we made a sequencer based on Galileo, SparkFun MP3 shield and the sketch ReadMP3fromSD originally created by Nathan Seidle.
/*
Galileo Sequencer
This sketch is used for a demo of the Intel Galileo board. When it was launched in Rome Maker fair 2013,
we made a sequencer based on Galileo, SparkFun MP3 shield and the sketch ReadMP3fromSD originally created
by Nathan Seidle.
The sequencer has 2 knobs, 4 buttons and 8 leds on its interface. When activated, it loops through and
plays 8 segments of sound samples repeatedly. At the mean time, the LEDs will light up according to which
segment you’re listening to. You can use the buttons and knobs to customize and add creativity into the sequence.
@ashumeow
ashumeow / move_postgres_data_to_ram.bash
Last active August 29, 2015 14:26 — forked from zekefast/move_postgres_data_to_ram.bash
Move Postgres data_directory to RAM to improve IO speed and test performance. Run as root/sudo.
#!/bin/bash
# It is probably redundant if you set settings mentioned in https://gist.github.com/zekefast/42273658939724ba7c7a .
# But anyway it will not hurt anybody (sure if you are not putting your production database to RAM :)).
#
# Look for more detailed description in follow articles:
# - http://blog.vergiss-blackjack.de/2011/02/run-postgresql-in-a-ram-disk/
#
# ATTENTION:
# DO NOT apply this approach if you store important data in postgresql cluster, because that could cause
/**
* file: images.json
*/
{
"images": [
{"title": "Image One", "url": "image1.jpg", "rating": "3.5"},
{"title": "Image Two", "url": "image2.jpg", "rating": "1"},
{"title": "Image Three", "url": "image3.jpg", "rating": "5"}
]
}
import pyscene
scene = pyscene.pyscene()
import osg, osgDB
import math, re, os
scene.setScale(5e4, 0.5)
scene.viewer.getCamera().setClearColor(osg.Vec4f(0, 0, 0, 0))
mars = scene.readNodeFile("mars.osg")
# make the north pole face up instead of down

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@ashumeow
ashumeow / handy.py
Last active August 29, 2015 14:24 — forked from rainyear/handy.py
#!/usr/bin/env python
import cv2
import numpy as np
def main():
cap = cv2.VideoCapture(0)
while(cap.isOpened()):
ret, img = cap.read()
skinMask = HSVBin(img)