This is a collection of quick and helpful JS tips or code snippets that might be useful in various circumstances.
I hereby claim:
- I am nikaspran on github.
- I am nikaspran (https://keybase.io/nikaspran) on keybase.
- I have a public key whose fingerprint is D50C CC9B 729B B563 1FBB EC86 6112 C64F D377 F37D
To claim this, I am signing this object:
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
initDb | |
.then(function () { | |
return project.save(); | |
}) | |
.then(function () { | |
return Environment.destroy(); | |
}) | |
.then(function () { | |
done(); | |
}); |
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 strict'; | |
function bootstrap(element, modules) { | |
element = $(element); | |
modules = modules || []; | |
// modules.unshift(['$provide', function ($provide) { | |
// $provide.value('$rootElement', element); | |
// }]); | |
modules.unshift('ng'); | |
var injector = element.injector(); |
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
server.get('/api/entities', function (req, res, next) { | |
var criteria = new Predicates.Criteria(server.db); | |
criteria.select('Entity').from('Entity'); | |
if (req.query.type) { | |
criteria.add(Predicates.eq('Entity.type', req.query.type)); | |
} | |
if (req.query.name) { //TODO: escape regex | |
criteria.add(Predicates.match('Entity.name', '^' + req.query.name)); |
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
server.get('/api/relations', function (req, res, next) { | |
var predicates = []; | |
if (req.query.type) { | |
predicates.push(Predicates.eq('type', req.query.type)); | |
} | |
if (req.query.sourceId) { | |
predicates.push(Predicates.eq('sourceId', req.query.sourceId)); | |
} |
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
/*jshint expr:true */ | |
'use strict'; | |
var Entity = require('./../model/Entity')(schema); | |
require('./EntityController')(server, schema); | |
describe('EntityController', function () { | |
it('should GET single', function (done) { | |
var entity = new Entity(); | |
entity.name = 'Test'; |
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
import Bio.Blast.NCBIWWW | |
import Bio.Blast.NCBIXML | |
import Bio.Blast.Record | |
import Bio.Align.Applications | |
import Bio.SeqIO | |
from StringIO import StringIO | |
from Bio.SeqRecord import SeqRecord | |
from Bio.Seq import Seq | |
from Bio.Alphabet import generic_protein | |
from Bio.Align.Applications import MafftCommandline |
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
def filter_by_min_positives(blast_results, minPositivesPercent): | |
correct_indices = [] | |
for index, sequence in enumerate(blast_results.alignments): | |
if sequence.hsps[0].positives * 100.0 / sequence.length >= minPositivesPercent: | |
correct_indices.append(index) | |
filtered_results = Bio.Blast.Record.Blast() | |
filtered_results.multiple_alignment = blast_results.multiple_alignment | |
for index in correct_indices: |
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
-- ecris schema queue @ CRDB | |
CREATE USER ecris IDENTIFIED BY ecris | |
DEFAULT TABLESPACE tab | |
TEMPORARY TABLESPACE temp; | |
GRANT CONNECT, RESOURCE, aq_administrator_role TO ecris; | |
begin |