Skip to content

Instantly share code, notes, and snippets.

View gate3's full-sized avatar

Doyin Olarewaju gate3

View GitHub Profile
@taylorza
taylorza / GO-Fillslice.md
Last active May 5, 2024 05:51
Golang - Fill slice/array with a pattern

Filling an array or slice with a repeated pattern

Looking for an efficient pure GO approach to copy repeating patterns into a slice, for a toy project, I ran a few tests and discovered a neat approach to significantly improve performance. For the toy project, I am using this to fill a background buffer with a specific RGB color pattern, so improving this performance significantly improved my acheivable framerate.

All the test were run with a buffer of 73437 bytes, allocated as follows

var bigSlice = make([]byte, 73437, 73437)

Fill the slice with the value 65 by looping through each element and setting the value

@PhirePhly
PhirePhly / Makefile
Created June 12, 2012 03:12
A crazy simple SMTP server, for educational purposes only.
default:
cc ccsmtp.c -o ccsmtpd -lpthread
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@ashleydw
ashleydw / nginx.conf
Last active January 8, 2024 15:32
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@yanmhlv
yanmhlv / example.go
Created February 8, 2016 14:49
JSONB in gorm
package main
import (
"database/sql/driver"
"encoding/json"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
@mojavelinux
mojavelinux / nodegit-private-clone-test.js
Created May 21, 2018 08:45
Clone a private repository using nodegit
const git = require('nodegit')
const fs = require('fs-extra')
const { URL } = require('url')
const REPO_URL = 'git@github.com:org/path.git'
const CLONE_DIR = '/tmp/private-repo-clone-test'
;(async () => {
await fs.emptyDir(CLONE_DIR)
let authAttempted = false
await git.Clone.clone(REPO_URL, CLONE_DIR, {
@jcbagtas
jcbagtas / auth.php
Last active August 23, 2021 12:11
Get current Laravel active session from outside laravel instance. Laravel 5.2
<?php
/**
* Get current Laravel active session from outside laravel instance.
* Tested Laravel 5.2
*
*
*/
function getLaravelUser()
{
require __DIR__ . '\path\to\bootstrap\autoload.php';
@gustavlrsn
gustavlrsn / Layout.js
Created May 1, 2017 18:11
Example bootstrap 4 integration into Next.js, with the reactstrap package
import Head from 'next/head'
import { Container } from 'reactstrap'
const Layout = (props) => (
<div>
<Head>
<title>PairHub</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
</Head>
@gate3
gate3 / nodegit-private-clone-test.js
Created July 15, 2019 13:47 — forked from mojavelinux/nodegit-private-clone-test.js
Clone a private repository using nodegit
const git = require('nodegit')
const fs = require('fs-extra')
const { URL } = require('url')
const REPO_URL = 'git@github.com:org/path.git'
const CLONE_DIR = '/tmp/private-repo-clone-test'
;(async () => {
await fs.emptyDir(CLONE_DIR)
let authAttempted = false
await git.Clone.clone(REPO_URL, CLONE_DIR, {
@tiagopereira17
tiagopereira17 / OddOccurrencesInArray.java
Created June 22, 2016 00:42
A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
public class OddOccurrencesInArray {
public int solution(int[] A) {
if(A == null || A.length == 0) {
return 0;
}
if(A.length == 1) {
return A[0];
}