Friday, December 2, 2016

Angularjs filter number to scientific number

How to fetch local db in android apps?

Steps to get local db in android apps:
:: For copy database file to desktop and get permission

adb shell 

run-as com.utryfirst.student  
chmod 666 databases/pencil_local_db.db  

exit

cp /data/data/com.utryfirst.student/databases/pencil_local_db.db /sdcard/
run-as com.utryfirst.student  

chmod 600 databases/pencil_local_db.db  
exit

exit
adb pull /sdcard/pencil_local_db.db


Thursday, December 1, 2016

PHP function to calculate standard deviation

// Function to calculate square of value - mean
function sd_square($x, $mean) { return pow($x - $mean,2); }

// Function to calculate standard deviation (uses sd_square)    
function sd($array) 
{
    if(count($array)> 0):
    return sqrt(
            array_sum(array_map("sd_square", 
                            $array, 
                            array_fill
                                    (
                                        0,
                                        count($array), 
                                        (array_sum($array) / count($array)) 
                                    ) 
                                ) 
                    ) / (count($array)-1) );
    endif;
}

SyntaxHighlighter 3.0.83

How to use? E.g:
<pre class="bursh:php">
</pre>

SyntaxHighlighter uses separate syntax files called brushes to define its highlighting functionality.
Brush nameBrush aliasesFile name
ActionScript3as3, actionscript3shBrushAS3.js
Bash/shellbash, shellshBrushBash.js
ColdFusioncf, coldfusionshBrushColdFusion.js
C#c-sharp, csharpshBrushCSharp.js
C++cpp, cshBrushCpp.js
CSScssshBrushCss.js
Delphidelphi, pas, pascalshBrushDelphi.js
Diffdiff, patchshBrushDiff.js
Erlangerl, erlangshBrushErlang.js
GroovygroovyshBrushGroovy.js
JavaScriptjs, jscript, javascriptshBrushJScript.js
JavajavashBrushJava.js
JavaFXjfx, javafxshBrushJavaFX.js
Perlperl, plshBrushPerl.js
PHPphpshBrushPhp.js
Plain Textplain, textshBrushPlain.js
PowerShellps, powershellshBrushPowerShell.js
Pythonpy, pythonshBrushPython.js
Rubyrails, ror, rubyshBrushRuby.js
ScalascalashBrushScala.js
SQLsqlshBrushSql.js
Visual Basicvb, vbnetshBrushVb.js
XMLxml, xhtml, xslt, html, xhtmlshBrushXml.js
Credit to: http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

Monday, November 21, 2016

Dummy data for pfm_student_subject


(student_id,

subject_code_id,

dt_update,

short_name,

overall_accuracy,

overall_coverage,

last_three_months_coverage,

last_three_months_accuracy)



SELECT * FROM (

SELECT

85,

e.subject_code_id,

(NOW() - INTERVAL ROUND((RAND() * (90-0))+0) DAY) as dt_update,

ec.short_name,

ROUND(AVG((RAND() * (100-0))+0)) as overall_accuracy,

ROUND(AVG((RAND() * (100-0))+0)) as overall_coverage,

ROUND(AVG((RAND() * (100-0))+0)) as last_three_months_coverage,

ROUND(AVG((RAND() * (100-0))+0)) as last_three_months_accuracy

FROM edu_student_subject e

LEFT JOIN edu_subject_code ec ON ec.subject_code_id = e.subject_code_id

WHERE e.student_id=85

GROUP BY e.subject_code_id) as tbl1



ON DUPLICATE KEY UPDATE

dt_update = tbl1.dt_update,

short_name = tbl1.short_name,

overall_accuracy = tbl1.overall_accuracy,

overall_coverage = tbl1.overall_coverage,

last_three_months_coverage = tbl1.last_three_months_coverage,

last_three_months_accuracy = tbl1.last_three_months_accuracy;