Skip to content

Instantly share code, notes, and snippets.

@dewdad
dewdad / 0_reuse_code.js
Created February 5, 2014 18:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dewdad
dewdad / new_gist_file_0
Created February 5, 2014 18:43
Overriding xmlhttprequest open to tamper with requests in JavaScript apps From http://stackoverflow.com/questions/7775767/javascript-overriding-xmlhttprequest-open
(function() {
var proxied = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function() {
console.log( arguments );
return proxied.apply(this, [].slice.call(arguments));
};
})();
/*
["POST", "/ajax/chat/buddy_list.php?__a=1", true]
@dewdad
dewdad / designer.html
Created July 15, 2014 19:21
designer
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@dewdad
dewdad / jsbin.sudicu.html
Created July 21, 2014 11:23
A single page test template for SAPUI5 and OData
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SAPUI5 BlueCrystal Example using Mock Service</title>
<script id='sap-ui-bootstrap'
src='https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-debug="true"
type="text/javascript" data-sap-ui-libs="sap.m, sap.me"
@dewdad
dewdad / proxy.js
Last active August 29, 2015 14:12 — forked from jasper07/proxy.js
var express = require('express'),
httpProxy = require('http-proxy'),
proxy = new httpProxy.createProxyServer();
var routing = {
'sapui5': {
target: 'http://localhost:8001' //sdk
},
'apps': {
target: 'http://localhost:8002' //applications
@dewdad
dewdad / designer.html
Last active September 3, 2015 09:04
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@dewdad
dewdad / index.md
Created February 15, 2018 08:03 — forked from mathisonian/index.md
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@dewdad
dewdad / ProxySettings.java
Created March 4, 2018 10:32 — forked from madeye/ProxySettings.java
Set proxy for Android Webview
package me.madeye;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.http.HttpHost;
import android.content.Context;
@dewdad
dewdad / Reset-BashPassword.ps1
Created April 29, 2018 11:32 — forked from richardszalay/Reset-BashPassword.ps1
Reset-BashPassword.ps1
# Resets the password for the default LXSS / WSL bash user, based on https://askubuntu.com/a/808425/697555
$lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername
@dewdad
dewdad / interceptors.js
Created June 10, 2018 11:30 — forked from javisperez/interceptors.js
Axios interceptor for cache with js-cache
// Usually I use this in my app's config file, in case I need to disable all cache from the app
// Cache is from `js-cache`, something like `import Cache from 'js-cache';`
const cacheable = true,
cache = new Cache();
// On request, return the cached version, if any
axios.interceptors.request.use(request => {
// Only cache GET requests
if (request.method === 'get' && cacheable) {