Skip to content

Instantly share code, notes, and snippets.

@lambdamusic
lambdamusic / toggle.js
Last active April 4, 2024 22:04
Jquery: click and toggle #js
$('#clickme').click(function() {
$('#book').toggle('slow', function() {
// Animation complete.
});
});
@lambdamusic
lambdamusic / Snipplr-42631.js
Last active April 4, 2024 22:04
JavaScript: Reload an image with jQuery #js
// There is no reload or replace method for images. The src property can be set in the same way as the location.href property though.
with($('#image')) {
src = src.replace(/\?.*$/, '') + '?' + Math.random();
}
@lambdamusic
lambdamusic / Snipplr-37624.js
Last active April 4, 2024 22:04
JavaScript: Go to top of page using jQuery #js
$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
// or
$( 'html, body' ).animate( { scrollTop: 0 }, 'slow' );
@lambdamusic
lambdamusic / Snipplr-36620.js
Last active April 4, 2024 22:04
JavaScript: JQuery Accordion: retrieve active tab / open dynamically #js
// imagine the accordion is started like this:
$("#accordion").accordion({ header: 'h5', collapsible: true , active: false});
// this gets you the index of open accordion [0.....n]
$("#accordion h5").index($("#accordion h5.ui-state-active"));
// let's save that index.. and use it to activate/deactivate the tab
n = $("#accordion h5").index($("#accordion h5.ui-state-active"));
$('#accordion').accordion('activate', n);
@lambdamusic
lambdamusic / researchers1.sql
Last active April 4, 2024 22:01
GBQ Dimensions: return researchers and their publication count #sql
-- Return researchers and their publication count
-- LIMITED TO
-- publications with FOR “11 Medical and Health Sciences”
-- WHERE
-- Researcher is from Canada, Austria, Belgium, Czech Rep, Denmark, Finland, France, Australia
-- Researcher did NOT publish in the 2018, 2019, 2020 in a journal from publisher “Public Library of Science (PLoS)”
-- Researcher has email address
-- number of publications is minimum 3
-- sorted by
-- publication count
@lambdamusic
lambdamusic / researchers.sql
Last active April 4, 2024 22:00
GBQ Dimensions: Getting researchers based on two criteria #sql
-- Pub criteria:
-- FOR code
-- Specific journals
-- Year
-- Author criteria:
-- FCR (of any paper for last 5 years) > 1.5
-- Last publication < 24 months ago
-- Total publications > 7
@lambdamusic
lambdamusic / covid19-tutorial-1.sql
Last active April 4, 2024 21:59
GBQ COVID-19 dataset sample query #sql
SELECT
p.id,
p.title.preferred AS title,
p.doi,
p.year,
p.journal.title,
p.type,
p.date AS date_publication,
p.date_inserted,
FROM
@lambdamusic
lambdamusic / arrays.sql
Last active April 4, 2024 21:57
GBQ Arrays examples with Dimensions #sql
-- example 1
-- unnest an array in line so to perform an aggregation
select
id,
(SELECT MAX(e) from UNNEST(email) e) as first_email
from `dimensions-ai.data_analytics.researchers` r
WHERE ARRAY_LENGTH(email) > 0
LIMIT 10
@lambdamusic
lambdamusic / scigraph_context.json
Last active April 4, 2024 20:37
SciGraph context (preview) #jsonld
# source: https://github.com/springernature/scigraph/blob/master/2018Q3/context/scigraph.json
{
"@context": {
"@vocab": "http://schema.org/",
"@base": null,
"sg": "http://scigraph.springernature.com/id/",
"sgo": "http://scigraph.springernature.com/ontologies/core/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
@lambdamusic
lambdamusic / Snipplr-29633.py
Created February 7, 2013 21:26
Python: MySQL-Python library #python #sql
import MySQLdb
conn = MySQLdb.connect(host=\"localhost\", user=\"root\", passwd=\"nobodyknow\", db=\"amit\")
cursor = conn.cursor()
stmt = \"SELECT * FROM overflows\"
cursor.execute(stmt)
# Fetch and output
result = cursor.fetchall()