Skip to content

Instantly share code, notes, and snippets.

@mandaputtra
mandaputtra / config.lua
Last active May 21, 2024 05:33
My lvim configuration
-- vim options
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.relativenumber = true
-- general
lvim.log.level = "info"
lvim.format_on_save = {
enabled = true,
pattern = "*.lua,*.js,*.ts,*.py",
@tarek360
tarek360 / CurvedShape.dart
Last active February 8, 2023 00:54
Draw a curved shape in Flutter
import "package:flutter/material.dart";
import 'package:flutter/services.dart';
import 'dart:math';
const CURVE_HEIGHT = 160.0;
const AVATAR_RADIUS = CURVE_HEIGHT * 0.28;
const AVATAR_DIAMETER = AVATAR_RADIUS * 2;
void main() => runApp(new MyApp());
@amad-person
amad-person / gist:f0ef85a2123a2e1fcf8052dcf09eef90
Last active August 12, 2023 17:38
Bypass CSP restrictions in create-react-app Chrome extensions

While building a React Chrome extension using the create-react-app utility (v2.x), I came across the following error on loading my unpacked extension:

Refused to execute inline script because it violates the following Content Security Policy directive: “script-src ‘self’
blob: filesystem: chrome-extension-resource:”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-
GgRxrVOKNdB4LrRsVPDSbzvfdV4UqglmviH9GoBJ5jk=’), or a nonce (‘nonce-…’) is required to enable inline execution.

Basically, this error arises as Chrome (or almost any modern browser) will not allow inline scripts to get executed. This CSP restriction resulted in the above error as the build script in create-react-app bundles the .js files in <script> tags in the <body> of index.html.

@zyjibmcn
zyjibmcn / db2-temporary-tablespace
Created September 30, 2017 00:03
db2 临时表空间不足的问题
最近从生产库dump一个几十万的表,import到本地库时,排序查询会报以下错误:
A temporary table could not be created because there is no available system temporary table space that has a compatible page size.. SQLCODE=-1585, SQLSTATE=54048, DRIVER=3.63.123
解决办法:
db2 "create bufferpool ibmdefault8k IMMEDIATE SIZE 5000 PAGESIZE 16K"
db2 "CREATE TEMPORARY TABLESPACE mytmptbs PAGESIZE 16K MANAGED BY SYSTEM USING ('/home/db2inst1/tmp_tbs1') EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL IBMDEFAULT16K OVERHEAD 24.10 TRANSFERRATE 0.90 DROPPED TABLE RECOVERY OFF"
OS=`echo \`uname\` | tr '[:upper:]' '[:lower:]'`
AURL="https://gist.githubusercontent.com/hightemp/5071909/raw/"
ANAME=".bash_aliases"
TMPAPATH="/tmp/$ANAME"
HOMEAPATH="~/$ANAME"
[ "$OS" = "windowsnt" ] && OS_WIN="yes"
[ "$OS" = "darwin" ] && OS_MAC="yes"
[ "$OS" = "linux" ] && OS_LIN="yes"
@ericelliott
ericelliott / env-examples.md
Last active September 6, 2024 18:12
env-examples

Most configuration really isn't about the app -- it's about where the app runs, what keys it needs to communicate with third party API's, the db password and username, etc... They're just deployment details -- and there are lots of tools to help manage environment variables -- not the least handy being a simple .env file with all your settings. Simply source the appropriate env before you launch the app in the given env (you could make it part of a launch script, for instance).

env files look like this:

SOMEVAR="somevalue"
ANOTHERVAR="anothervalue"

To source it:

$ source dev.env # or staging.env, or production.env, depending on where you're deploying to