Skip to content

Instantly share code, notes, and snippets.

View richard457's full-sized avatar
🎯
Focusing

Muragijimana richard457

🎯
Focusing
View GitHub Profile
@richard457
richard457 / ssh-chroot-jail.sh
Created March 10, 2019 07:30 — forked from floudet/ssh-chroot-jail.sh
Chroot Jail for SSH Access
# Chroot Jail for SSH Access
# Tested on Ubuntu 14.04.2 LTS and Debian GNU/Linux 8 (jessie)
# Reference : http://allanfeid.com/content/creating-chroot-jail-ssh-access
#
# Had to add/change several things to make it work, including:
# - create lib64 folder
# - copy whoami dependencies that ldd doesn't show to fix 'I have no name!'
# in the customized prompt + create passwd file
#
@richard457
richard457 / Clean a dirty string
Created March 14, 2019 09:25
Cleaning a string in JavaScript.
let dirtyString= "[Hello world]";
dirtyString.replace(/([^a-z0-9]+)/gi, '');
console.log(dirtyString); // Hello world
@richard457
richard457 / migration.php
Created March 19, 2019 09:55 — forked from jakzaizzat/migration.php
Update ENUM value in Laravel Migration
DB::statement("ALTER TABLE roles CHANGE COLUMN role role ENUM('system admin', 'super admin', 'admin staff', 'instructor', 'customer', 'gym member', 'swim member')");
<?php
// GET
$request = $client->get($url, array('Accept' => 'application/json'));
$response = $request->send();
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
// Error
}
import 'package:flutter/material.dart';
class CustomSliderThumbCircle extends SliderComponentShape {
final double thumbRadius;
final int min;
final int max;
const CustomSliderThumbCircle({
@required this.thumbRadius,
this.min = 0,
@richard457
richard457 / main.dart
Created September 16, 2020 07:24
Text does not start on the same line.
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class User{
List<String> numbers;
}
@richard457
richard457 / RotateArrayByKStep
Created February 20, 2021 18:49
Rotate Array given K step.
public static void rotate(int [] arr, int k){
int j =0;
while(k>0){
int temp = arr[arr.lenght -1]
for(j=arr.lenght -1; j>0; j--){
arr[j] = arr[j-1]
}
arr[j] = temp;
k--;
}
@richard457
richard457 / example.nginx
Created May 14, 2022 18:40 — forked from gsanders5/example.nginx
Automatic nginx virtual subdomains with sub-folders or sub-directories
# Automatic nginx virtual subdomains with sub-folders or sub-directories
#
# Since the original source where I found this code is now offline, I have decided to mirror it here.
# All credit goes to: http://web.archive.org/web/20150307193208/http://www.messaliberty.com/2010/10/automatic-nginx-virtual-subdomains-with-sub-folders-or-sub-directories
#
# Description: In my web root directory I wanted create a folder called photos, and another called
# music using a sftp program. Without manually going back to the config file or to the shell I like to
# be able to access them at photos.nginxdomain.com and music.nginxdomain.com. That is what this config does.
# Redirect visitors from http://nginxdomain.com/ to http://www.nginxdomain.com/
@richard457
richard457 / main.dart
Last active May 24, 2022 17:37
InvoiceGenerator
import 'dart:math';
import 'package:intl/intl.dart';
import 'dart:math' as math;
void main() {
var random = math.Random();
var randomNumber = '';
for (var i = 0; i < 10; i++) {
randomNumber += random.nextInt(10).toString();
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.