Skip to content

Instantly share code, notes, and snippets.

@atchim
atchim / node_motion.lua
Last active May 11, 2024 06:07
Neovim Tree-Sitter node motion
local api = vim.api
local ctrlv = api.nvim_replace_termcodes('<C-V>', true, true, true)
local function exit_vmode()
local mode = vim.fn.mode()
if mode == 'v' or mode == 'V' or mode == ctrlv then
vim.cmd('normal! ' .. mode)
end
end
@JT501
JT501 / useCountDown.ts
Last active July 18, 2023 04:25
React useCountDown Hook
import { useEffect, useRef, useState } from 'react';
export const useCountDown: (
total: number,
ms?: number,
) => [number, () => void, () => void, () => void] = (
total: number,
ms: number = 1000,
) => {
const [counter, setCountDown] = useState(total);
@MarcinusX
MarcinusX / infinite_listview.dart
Created April 16, 2018 19:47
This is source code for a blog post.
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
@branflake2267
branflake2267 / main.dart
Created March 3, 2018 21:32
Flutter - Using the future builder with infinite list view.
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
@ram535
ram535 / gist:b1b7af6cd7769ec0481eb2eed549ea23
Last active February 2, 2023 12:25
Reuse the same terminal in neovim.
" With this function you can reuse the same terminal in neovim.
" You can toggle the terminal and also send a command to the same terminal.
let s:monkey_terminal_window = -1
let s:monkey_terminal_buffer = -1
let s:monkey_terminal_job_id = -1
function! MonkeyTerminalOpen()
" Check if buffer exists, if not create a window and a buffer
if !bufexists(s:monkey_terminal_buffer)
@kolosek
kolosek / ubuntu-install-nodejs-npm.sh
Last active December 24, 2018 14:21
Install node.js version 6.x Ubuntu 16.04
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
echo "Installing NodeJS 6.x"
sudo apt-get install nodejs
echo "Install webpack globally"
sudo npm install webpack -g
echo "Install nightwatch globally"
sudo npm install nightwatch -g
@monkut
monkut / Ubuntu1604py36Dockerfile
Last active June 14, 2023 20:31
Base Docker image for ubuntu-16.04 & Python3.6
# docker build -t ubuntu1604py36
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git
#!/bin/sh
KERNEL_VERSION="3.13.0-29"
sudo apt-get update
sudo aptitude install -y linux-image-${KERNEL_VERSION}-generic \
linux-headers-${KERNEL_VERSION} linux-image-extra-${KERNEL_VERSION}-generic
sudo sed -i "s/GRUB_DEFAULT=.*/GRUB_DEFAULT=\"Advanced options for Ubuntu>Ubuntu, with Linux ${KERNEL_VERSION}-generic\"/" /etc/default/grub
sudo update-grub
@alirussell
alirussell / is_british_summertime.js
Last active April 15, 2024 09:25
Check for british summer time (BST) in JavaScript
function lastSunday(month, year) {
var d = new Date();
var lastDayOfMonth = new Date(Date.UTC(year || d.getFullYear(), month+1, 0));
var day = lastDayOfMonth.getDay();
return new Date(Date.UTC(lastDayOfMonth.getFullYear(), lastDayOfMonth.getMonth(), lastDayOfMonth.getDate() - day));
}
function isBST(date) {
var d = date || new Date();
var starts = lastSunday(2, d.getFullYear());
@tgrall
tgrall / sec_tutorial.md
Last active September 4, 2020 07:27
MongoDB Security Tutorial

#Simple MongoDB Security Tutorial

###1 - Start mongod without any "security option"

$ mongod --port 27017