Skip to content

Instantly share code, notes, and snippets.

@MrToph
MrToph / google-drive.js
Last active April 16, 2024 12:36
Google Drive API v3 fetch
import GoogleSignIn from 'react-native-google-sign-in'
const url = 'https://www.googleapis.com/drive/v3'
const uploadUrl = 'https://www.googleapis.com/upload/drive/v3'
const boundaryString = 'foo_bar_baz' // can be anything unique, needed for multipart upload https://developers.google.com/drive/v3/web/multipart-upload
let apiToken = null
@goloroden
goloroden / app.js
Last active June 22, 2023 02:10
Async constructors for JavaScript
// In JavaScript, constructors can only be synchronous right now. This makes sense
// from the point of view that a constructor is a function that returns a newly
// initialized object.
//
// On the other hand, it would sometimes be very handy, if one could have async
// constructors, e.g. when a class represents a database connection, and it is
// desired to establish the connection when you create a new instance.
//
// I know that there have been discussions on this on StackOverflow & co., but
// the so-far mentioned counter arguments (such as: doesn't work as expected
@mikermcneil
mikermcneil / using-raw-socket-io-in-sails.js
Created September 17, 2013 18:32
Using raw socket.io functionality in a Sails.js controller
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
@longhotsummer
longhotsummer / leaflet-big-image-full.html
Created April 5, 2016 06:47
Full example of using leaflet to pan and zoom a big image, as described at http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html
<html>
<!-- See also: http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html -->
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"></script>
<style>
#image-map {
width: 100%;
height: 300px;
border: 1px solid #ccc;
margin-bottom: 10px;
@gustavlrsn
gustavlrsn / Layout.js
Created May 1, 2017 18:11
Example bootstrap 4 integration into Next.js, with the reactstrap package
import Head from 'next/head'
import { Container } from 'reactstrap'
const Layout = (props) => (
<div>
<Head>
<title>PairHub</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
</Head>
@saumyasuhagiya
saumyasuhagiya / blob_image_save_fetch_node_sequelize.js
Last active March 26, 2020 07:48
Mysql blob image retrieval and insert operation using sequelize package of node.js
var DATABASE_NAME = 'test_db';
var DB_USERNAME = 'abc';
var DB_PASSWORD = 'abc@123';
var Sequelize = require('sequelize');
var FS = require('fs');
var sequelize = new Sequelize(
DATABASE_NAME,
DB_USERNAME,