Skip to content

Instantly share code, notes, and snippets.

export function setScreenReaderTitle() {
const $heading = $('h1').first();
// If the heading exists and nothing else has focus
if ($heading.length && $(document.activeElement).is('body')) {
$heading.attr('tabindex', -1);
$heading.focus();
}
}
.screen-reader-text {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
}
if (res.response.code == "valid") {
// verification code is correct
$('.validation').removeClass('invalid').addClass('valid');
$('.verify-btn-wrapper .screen-reader-text').text('Code verified');
} else {
// verification code is incorrect
$('.validation').removeClass('valid').addClass('invalid');
$('.verify-btn-wrapper .screen-reader-text').text('Invalid code');
}
<fieldset>
<legend>2. Enter your 6-digit code:</legend>
<div class="verify-btn-wrapper">
<input type="text"
pattern="\d*"
name="code"
size="6"
autocomplete="off"
aria-label="verification code"
aria-required="true">
put
#!/usr/bin/env python
in python script
in terminal:
chmod ugo+rwx filename.py
./filename.py
valgrind --tool=memcheck --leak-check=yes ./executable_name -args
//find square root of x with binary search
double sqrt (double x) {
if (x == 0 || x == 1)
return x;
double low = 0, high = x/2, mid;
double precision = 0.0001;
while (high - low <= precision) {
mid = low + (high - low) / 2; //avoid integer overflow

Keybase proof

I hereby claim:

  • I am connieqi on github.
  • I am cq (https://keybase.io/cq) on keybase.
  • I have a public key whose fingerprint is 57CC DD9D 5F9E 2173 3762 D8A5 F7FA C036 014C 0AC0

To claim this, I am signing this object:

@connieqi
connieqi / Makefile
Created April 18, 2014 03:26
Makefile magic
test%: test%.cpp
g++ test$@.cpp $(FLAGS) -o test$@
@connieqi
connieqi / bsearch.cpp
Last active December 16, 2015 04:49
Optimized binary search code
template <class Iterator, class Value>
Iterator bsearch(Iterator from, Iterator to, Value key{
if(from >= to) return nullptr;
while(from < to){
Iterator mid = from+ (to - from)/2;
if(*mid < key)
from = mid + 1;
else
to = mid;
}