Skip to content

Instantly share code, notes, and snippets.

View madeindjs's full-sized avatar
💩

Alexandre Rousseau madeindjs

💩
View GitHub Profile
@madeindjs
madeindjs / sketchup_change_color.rb
Created October 14, 2016 14:59
Sketchup script to quickly change colors on many Sketchup::ComponentInstance
# search all Sketchup::ComponentInstance included partial_name and apply a material
def apply_material_on_all_instance material_name, partial_name
material = Sketchup.active_model.materials[material_name]
Sketchup.active_model.definitions.each{|d| 
if d.name.include? partial_name
puts d.name
d.instances.each{ |inst|
inst.material = material
puts "\tinstance colored"
}
@madeindjs
madeindjs / synchronize.rb
Created October 14, 2016 15:06
Synchronize Sketchup files between two directory
if File.extname(file) == '.skp'
file_src  = File.join $remote_path, file
file_dest  = File.join $model_path, file
# if file already exists but a newer version exists on remote, we add it
if File.exists?(file_dest) and ( File.mtime(file_src).to_i > File.mtime(file_dest).to_i )
FileUtils.cp(file_src, file_dest)
puts "[*] #{file} %s" % $lHandler['updated']
yield "#{file} %s" % $lHandler['updated']
# if file not exists we add it to the local library
@madeindjs
madeindjs / convert_skp_files.rb
Last active November 30, 2016 13:16
convert all files from the given directory into the given format
# convert all files from the given directory into the given format
#
# @note For SketchUp Pro 7.1+, valid extensions include dae, kmz, 3ds, dwg, dxf, fbx, obj, wrl, and xsi. SketchUp Free only supports dae and kmz. (see http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#export)
#
# @param src_path [String] as path were sketchup files are stored
# @param dest_path [String] as output path after convertion
# @param export_format [String] as output format
def convert_sketchup_files src_path, dest_path, export_format
format_available = %w(dae kmz 3ds dwg dxf fbx obj wrl xsi pdf)
@madeindjs
madeindjs / upgrade-from-php-v-5-5-9-to-v-5-6.sh
Created October 30, 2016 18:37
Upgrade PHP 5.5 to PHP 5.6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
@madeindjs
madeindjs / install_PHP7.0_on_Raspberry_Pi.sh
Last active March 11, 2019 11:47
Install PHP7 on Raspberry PI
sudo apt-get update && sudo apt-get upgrade
echo "deb http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free" >> /etc/apt/sources.list
echo "#deb-src http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free" >> /etc/apt/sources.list
sudo gpg --keyserver pgpkeys.mit.edu --recv-key CCD91D6111A06851
sudo su
gpg --armor --export CCD91D6111A06851 | apt-key add -
exit
@madeindjs
madeindjs / DirectoryLister.php
Created November 25, 2016 16:27
List all files in the given directory into a Json prompt (or an array if you want)
<?php
/**
* Represent a custom Directory class more easy to use for my need
*/
class DirectoryLister implements JsonSerializable{
private $path;
/**
@madeindjs
madeindjs / defer.js
Created December 2, 2016 14:28
make script execution wait until jquery is loaded
function defer(method) {
if (window.jQuery)
method();
else
setTimeout(function() { defer(method) }, 50);
}
@madeindjs
madeindjs / Sketchup_improve_2015_to_2016.rb
Created December 9, 2016 16:09
A Sketchup script to do boring stuff tu improve my 2015 library to 2016
# Edit materials
Sketchup.active_model.materials.to_a.each do |mat|
case mat.name
when / Ext/
Sketchup.active_model.materials.remove(mat) unless mat.deleted?
when / Int/
@madeindjs
madeindjs / bootstrap.sh
Last active April 6, 2017 08:09
Basic setup for Linux mint developper desktop
#!/bin/bash
green='\e[0;32m'
darkred='\e[1;31m'
lightblue='\e[1;34m'
default='\033[0m'
echo -e "${darkred}***Bootstrap Linux Mint setup***${default}"
@madeindjs
madeindjs / Rakefile
Last active April 7, 2017 08:54
My Rakefile
require 'git'
require 'fileutils'
require 'date'
require 'pathname'
desc "Print directory-tree"
task :tree, [:folder, :folder_only] do |t, args|
args.with_defaults(:folder_only => false)
$folder_only = args.folder_only == "true"