Skip to content

Instantly share code, notes, and snippets.

View colormono's full-sized avatar
🤓
I’m learning as I go

Mariano Rivas colormono

🤓
I’m learning as I go
View GitHub Profile
@colormono
colormono / wp_custom_post_navigation.php
Last active October 13, 2021 01:00
[Customize the_post_navigation] #WordPress
Use WordPress default function to get next and previous post title with permalink something like this:
<?php // FOR PREVIOUS POST
$prev_post = get_previous_post();
$id = $prev_post->ID ;
$permalink = get_permalink( $id );
?>
<?php // FOR NEXT POST
$next_post = get_next_post();
$nid = $next_post->ID ;
@colormono
colormono / customHint.js
Last active October 25, 2018 20:56
[Custom hint] #LensStudio
// Custom Hint
// Events docs: https://lensstudio.snapchat.com/api/Events/
//@input SceneObject customHintSprite
function showCustomHint() {
if (script.customHintSprite) {
script.customHintSprite.enabled = true;
}
}
function hideCustomHint() {
@colormono
colormono / cameraEvents.js
Last active October 2, 2018 18:19
[Eventos para la camara] #LensStudio
// Cámara delantera
var eventFront = script.createEvent("CameraFrontEvent");
eventFront.bind(function (eventData){
print("front camera active");
});
// Cámara trasera
var eventBack = script.createEvent("CameraBackEvent");
eventBack.bind(function (eventData){
print("back camera active");
@colormono
colormono / toggleContent.js
Created September 19, 2018 19:35
[Toggle objects] Show hide objects in #LensStudio
// @input string startTrigger = MouthOpenedEvent { "label":"Start trigger", "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }
// @input string endTrigger = MouthClosedEvent { "label":"End trigger", "widget": "combobox", "values"
@colormono
colormono / mapNum.js
Last active March 14, 2019 15:13
[MapNum] Map number between range #LensStudio #JS
/**
* Map number between range
*/
function mapNum(input, in_min, in_max, out_min, out_max) {
return ((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
}
// Example
//var mapedNumber = mapNum(someNumVar, -15, 15, -1, 1);
@colormono
colormono / rotateObject.js
Created July 17, 2018 21:59
[LensStudioL: Rotate Object] #LensStudio
var DEG_TO_RAD = 0.0174533;
script.Mesh1.getTransform().setLocalRotation( quat.quatFromEuler( 90.0 * DEG_TO_RAD, 45.0 * DEG_TO_RAD, 0.0 * DEG_TO_RAD) );
@colormono
colormono / checkDistance.js
Last active October 9, 2018 19:19
[LensStudio: CheckDistance] #LensStudio
// Check the distance between two objects
//@input SceneObject objectA
//@input SceneObject objectB
//@input float distCheck
var pointA = script.objectA.getTransform().getWorldPosition();
var pointB = script.objectB.getTransform().getWorldPosition();
var distance = pointA.distance(pointB);
if(distance > script.distCheck){
print("Lejos: " + distance);
@colormono
colormono / triggers.js
Created July 17, 2018 16:34
[LensStudio: Select Trigget] #LensStudio
//@input string startTrigger = MouthOpenedEvent { "label":"trigger", "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }
function start()
{
print("Hello world.");
}
// Start trigger
var eventStart = script.createEvent(script.st
@colormono
colormono / timeDifference.js
Last active September 10, 2018 14:25
[LensStudio: Time difference] Tiempo transcurrido desde la última interacción #LensStudio
// -----JS CODE-----
// Variable to store what time particle started
var startTime;
function update() {
if (startTime) {
// Calculate how many seconds have elapsed since we've triggered particles
var ageTime = getTime() - startTime;
print('Age: ' + ageTime + ' seconds.');
}
@colormono
colormono / ipython3_mavericks.sh
Created January 17, 2018 16:52 — forked from rossov/ipython3_mavericks.sh
Install ipython3 on Mac OS X Mavericks
# Install ipython3 on Mac OS X Maverics
# Update brew
brew update
brew upgrade
# Install Python 3
brew install python3
# Install ipython