Skip to content

Instantly share code, notes, and snippets.

View salimchami's full-sized avatar
🏠
Working from home

Salim Chami salimchami

🏠
Working from home
View GitHub Profile
@mikaello
mikaello / group-objects-by-property.md
Last active October 26, 2025 18:51 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group array of JavaScript objects by keys

This fork of JamieMason's implementation changes the key parameter to be an array of keys instead of just a single key. This makes it possible to group by multiple properties instead of just one.

Implementation

const groupBy = keys => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = keys.map(key => obj[key]).join('-');
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@kojiujau
kojiujau / find_available_LDAP_number.sh
Last active March 28, 2024 17:46
To find next available LDAP number
#!/bin/bash
dn="dc=example,dc=com"
ldap_server='192.168.1.1'
group_name='group'
available_uidNumber=`expr $(ldapsearch -x -b ${dn} -h ${ldap_server} '(objectClass=posixAccount)' uidNumber | grep "uidNumber: " | sed "s|uidNumber: ||" | uniq | sort -n | tail -n 1) + 1 `
echo ${available_uidNumber}
available_gidNumber=`expr $(ldapsearch -x -b ${dn} -h ${ldap_server} '(objectClass=posixGroup)' gidNumber | grep "gidNumber: " | sed "s|gidNumber: ||" | uniq | sort -n | tail -n 1) + 1 `
echo ${available_gidNumber}
@psayre23
psayre23 / gist:c30a821239f4818b0709
Last active March 9, 2026 09:44
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@tbuschto
tbuschto / Mock.spec
Last active May 22, 2018 21:47
Examples for using mocks in Jasmine Tests
describe( "Mock examples:", function() {
var version = jasmine.version_ ? jasmine.version_.major : parseInt( jasmine.version, 10 );
var spyName = function( spy ) {
if( version === 1 ) {
return spy.identity;
} else {
return spy.and.identity()
}
@francoisblarel
francoisblarel / authHttp.js
Created March 18, 2014 11:24
How to wrap angular $http for authentification. From the O'Reilly Book on AngularJS.
// This factory is only evaluated once, and authHttp is memorized. That is,
// future requests to authHttp service return the same instance of authHttp
servicesModule.factory('authHttp', function($http, Authentication) {
var authHttp = {};
// Append the right header to the request
var extendHeaders = function(config) {
config.headers = config.headers || {};
config.headers['Authorization'] = Authentication.getTokenType() +
' ' + Authentication.getAccessToken();
};
@rob-murray
rob-murray / add_intellij_launcer
Last active December 1, 2025 22:50
Add Intellij launcher shortcut and icon for ubuntu
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/rob/.intellij-13/bin/idea.png
Name[en_US]=IntelliJ
@hofmannsven
hofmannsven / README.md
Last active February 24, 2026 02:03
Git CLI Cheatsheet
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@harlanji
harlanji / Demo.java
Created August 29, 2011 23:42
Best way to add custom converters to spring-data-mongodb?
MongoTemplate mongo = ...;
List<Converter> converters = new ArrayList<Converter>();
converters.add(new Converter<DBObject, Participant>() {
public Participant convert(DBObject s) {
throw new UnsupportedOperationException("Not supported yet 1.");
}
});
converters.add(new Converter<Participant, DBObject>() {