Skip to content

Instantly share code, notes, and snippets.

View diewland's full-sized avatar
✳️

diewland.eth diewland

✳️
View GitHub Profile
@diewland
diewland / image_resize.js
Created March 10, 2017 09:38
Resize image by html5 canvas
// http://stackoverflow.com/questions/23945494/use-html5-to-resize-an-image-before-upload
var IMGRZ_MAX_WIDTH = 500;
/* Utility function to convert a canvas to a BLOB */
var dataURLToBlob = function(dataURL) {
var BASE64_MARKER = ';base64,';
if (dataURL.indexOf(BASE64_MARKER) == -1) {
var parts = dataURL.split(',');
var contentType = parts[0].split(':')[1];
@diewland
diewland / bulma-always-hamburger-menu.css
Last active April 18, 2017 08:29
bulma.io, always use hamburger menu
.nav-right {
display: none;
}
.nav-toggle, .nav-menu.is-active {
display: block;
}
.nav-menu {
background-color: white;
box-shadow: 0 4px 7px rgba(10, 10, 10, 0.1);
left: 0;
@diewland
diewland / 3screens-vertical-coding.grid
Created May 9, 2017 07:43
GridMove 3 screens template ( hor - ver - hor )
[Groups]
NumberOfGroups = 8
[1]
TriggerTop = [Monitor1Top]
TriggerRight = [Monitor1Left] + [Monitor1Width] /2
TriggerBottom = [Monitor1Top] + [Monitor1Height] /2
TriggerLeft = [Monitor1Left]
@diewland
diewland / settings.json
Created July 7, 2017 13:53
VS Code User Settings
{
"window.zoomLevel": 0,
"vim.disableAnnoyingNeovimMessage": true,
"window.menuBarVisibility": "toggle",
"editor.fontFamily": "Droid Sans Mono",
"editor.fontSize": 15,
"workbench.colorTheme": "Sublime Material Theme - Dark",
"workbench.colorCustomizations": {
"editor.background": "#000"
}
@diewland
diewland / async-await-playground.js
Created August 4, 2017 03:53
JavaScript async/await playground
// utility
function stamp_time(text){
console.log(new Date().toLocaleTimeString(), text);
}
// mock process
function make_double(v){
return new Promise(function(res, rej){
setTimeout(x => {
res(v*2); // double value
@diewland
diewland / android_send_notification.java
Created September 18, 2017 03:30
Send android notification
// https://alvinalexander.com/android/how-to-create-android-notifications-notificationmanager-examples
public void showNotification(String s){
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
Notification notification = new NotificationCompat.Builder(this)
.setTicker("Demo")
.setSmallIcon(android.R.drawable.ic_menu_help)
.setContentTitle("Demo Notification")
.setContentText(s)
.setContentIntent(pi)
.setAutoCancel(true)
@diewland
diewland / handle-excel-clipboard.html
Last active August 31, 2023 11:32
Handle clipboard from Excel by javascript
<h1>Handle paste clipboard from excel by JS</h1>
<div id='out'></div>
<script>
// https://stackoverflow.com/a/38326762/466693
document.addEventListener('paste', function (event) {
window.clipText = event.clipboardData.getData('Text');
render_table(clipText);
});
@diewland
diewland / Python3 Virtualenv Setup.md
Created November 2, 2017 08:42 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@diewland
diewland / add_tag_to_word.js
Created December 15, 2017 04:53
Automatic add tag to specific words
'hello my name is diewland'.replace(/(diewland|name)/g, "<span class='hl'>$&</span>")
// "hello my <span class='hl'>name</span> is <span class='hl'>diewland</span>"
@diewland
diewland / foo.log
Created December 23, 2017 04:52 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred