Skip to content

Instantly share code, notes, and snippets.

View MSVCode's full-sized avatar

Vincent MSVCode

  • Indonesia
View GitHub Profile
@MSVCode
MSVCode / FileSaver.dart
Last active August 26, 2024 03:37
Save new text-based file in Flutter using "Save File Dialog" / "Document Chooser" in Android. Choose one between Java/Kotlin
import 'package:flutter/services.dart';
Future<String> saveFile(String mime, String name, String data) async {
const platform =
MethodChannel("com.msvcode.filesaver/save"); //unique channel identifier
try {
final result = await platform.invokeMethod("saveFile", {
"mime": mime,
"name": name,
"data": data,
@MSVCode
MSVCode / qrcode_bits.js
Last active August 1, 2019 16:35
Number of Bits for each QR-Code Version
// Written by MSVCode on GitHub
// Based on https://www.qrcode.com/en/about/version.html
// Array of Map, example code compatible with JS, TS, and Dart.
const qrBits = [
{"L":152, "M":128, "Q":104, "H":72}, //1
{"L":272, "M":224, "Q":176, "H":128},
{"L":440, "M":352, "Q":272, "H":208},
{"L":640, "M":512, "Q":384, "H":288},
{"L":864, "M":688, "Q":496, "H":368}, //5
@MSVCode
MSVCode / google_search.js
Last active December 21, 2017 07:44
Batch request of Google CSE API using ES6 Promises in NodeJS
const google = require('googleapis');
const customsearch = google.customsearch('v1');
const CX = 'your_custom_search_engine_key'; //https://cse.google.com/
const API_KEY = 'your_cse_api_key'; //https://developers.google.com/custom-search/json-api/v1/overview
function runSearchQuery(query, startFrom){
return new Promise(function(resolve,reject){
customsearch.cse.list({ cx: CX, q: query, auth: API_KEY, start:startFrom}, function (error, response) {
if (error) reject(error);
resolve(response.items);