Skip to content

Instantly share code, notes, and snippets.

@alash3al
alash3al / main.dart
Created March 24, 2022 12:34
elnews.app ui spaghetti code
import 'package:async_builder/async_builder.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:url_launcher/url_launcher.dart';
@p7cq
p7cq / Arch_Linux_Root_On_ZFS.md
Last active January 5, 2024 14:58
Install Arch Linux with Root on ZFS

Arch Linux Root on ZFS

Installation steps for running Arch Linux with root on ZFS using UEFI and systemd-boot. All steps are run as root.

Requires an Arch Linux image with ZFS built-in (see References).

In live environment

If using KVM, add a Serial number for each virtual disk and reboot the VM. The disks should now be available in /dev/disk/by-id as virtio-<Serial>.

@kylefox
kylefox / attachment-utils.js
Created October 17, 2018 15:58
Convert Base64 data URLs to File objects for Trix attachments
window.AttachmentUtils = (function() {
var BASE64_MARKER = ';base64,';
var Utils = {
// Takes a file size (in bytes) and returns a human-friendly string representation.
humanFileSize: function(size) {
if(size < 1) return "0 bytes";
// http://stackoverflow.com/a/20732091
package main
import (
"os"
"log"
"crypto/tls"
"crypto/x509"
)
func vpc(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
@MauricioMoraes
MauricioMoraes / access_postgresql_with_docker.md
Last active May 2, 2024 10:21
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@anselm-helbig
anselm-helbig / caching.rb
Created August 25, 2016 14:38
memoize macro for ruby
module Caching
def cache(method)
mod = Module.new do
define_method(method) do |*args, &block|
instance_variable_get("@#{method}") ||
instance_variable_set("@#{method}", super(*args, &block))
end
end
prepend mod
end
@littlemove
littlemove / my-ruby.el
Created March 18, 2016 11:40
Spacemacs: Code folding for ruby-mode
;; Code folding
(add-hook 'ruby-mode-hook
(lambda () (hs-minor-mode)))
(eval-after-load "hideshow"
'(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
@ParthDesai
ParthDesai / generic_demo.go
Last active September 3, 2021 09:54
Generic map function in golang
package main
import (
"fmt"
"reflect"
)
func main() {
r := genericMap([]int{1, 2, 3, 4}, func(x int) string {
return "Hello"
@ChrisLusted
ChrisLusted / db.rake
Last active September 19, 2016 07:51 — forked from romansklenar/db.rake
Rake tasks to maintain Postgres tables
# lib/tasks/db.rake
namespace :db do
desc 'Maintains database by running command as ANALYZE, VACUUM and REINDEX'
task maintain: :environment do
verbose = ENV['VERBOSE'].present?
connection = ActiveRecord::Base.connection
puts "Maintaining database #{connection.current_database} ..."
connection.execute("VACUUM FULL #{'VERBOSE' if verbose}")
connection.execute("ANALYZE #{'VERBOSE' if verbose}")
@emad-elsaid
emad-elsaid / gist:2c2524440e30a91273ce
Created August 4, 2014 07:12
ruby server and allow port on centos
$ ruby -run -e httpd . -p 9090
# iptables -A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT
# iptables -F