This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Launch external process, and populate QComboBox using output from the process: | |
void MainWindow::PopulateBitFormats(const QString& fileName) | |
{ | |
QProcess ConverterQuery; | |
ui->BitDepthCombo->clear(); | |
int extidx = fileName.lastIndexOf("."); | |
if(extidx > -1){ | |
QString ext = fileName.right(fileName.length()-extidx-1); // get file extension from filename | |
ConverterQuery.start(ConverterPath, QStringList() << "--listsubformats" << ext); // ask converter for a list of subformats for the given file extension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parenthesis.cpp : calculate all expressions containing n pairs of matched parentheses ... | |
// | |
#include <string> | |
#include <iostream> | |
void brackets(int availableOpenBrackets, int availableCloseBrackets, std::string s, int& combinationCount); | |
int main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <immintrin.h> | |
// Verify CPU capabilities: | |
bool bAVXok = false; | |
int cpuInfo[4] = { 0,0,0,0 }; | |
__cpuid(cpuInfo, 0); | |
if (cpuInfo[0] != 0) { | |
__cpuid(cpuInfo, 1); | |
if (cpuInfo[2] & (1 << 28)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isBrowserIE() { | |
var ua = window.navigator.userAgent; | |
var rv = false; | |
if (ua.indexOf('MSIE ') > 0) { // IE 10 or older | |
rv = true; | |
} | |
if (ua.indexOf('Trident/') > 0) { // IE 11 | |
rv = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DecimalToRoman.cpp : convert decimal number to Roman Numeral | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
struct symbol { | |
std::string name; | |
int value; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////////////////// | |
// testLineCircleIntersection() : test whether a line intersects with a circle | |
// x0,y0 : first point on line | |
// x1,y1 : second point on line | |
// ox,oy : center of circle | |
// r: radius of circle | |
// | |
// return value: | |
// < 0 : no intersection, | |
// = 0 : tangent (hits circle at one point), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// merge array of arrays into a single array | |
var data = [ | |
['a','b','c'], | |
['d','e','f'], | |
['g','h','i'], | |
]; // array of arrays | |
// merge results into a single array | |
var combinedData = [].concat.apply([], data); // ['a','b','c','d' ... 'i'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// detect if datepicker required (no input type="date" ...) | |
if ( $('[type="date"]').prop('type') != 'date' ) { | |
installDatePicker('dd-M-yy'); // note: with jQui datepicker, 'yy' is 4-digit year | |
} | |
// installs a jQueryUI datepicker in place of <input type="date">: | |
function installDatePicker(displayFormat) { | |
$('input[type=date]').each(function (index, element) { | |
var hiddenDate = $(this).clone().insertAfter(this).hide(); // create hidden date field that will contain the iso 8601 date format |
OlderNewer