Skip to content

Instantly share code, notes, and snippets.

@jampajeen
jampajeen / gist:442fbe2902a98fdb44582985f52c56f5
Created January 26, 2017 20:56
SSH to System VM from the Host on which the VM is running - cloudstack
Format: ssh -i <path-to-private-key> <link-local-ip> -p 3922
Example: root@faith:~# ssh -i /root/.ssh/id_rsa.cloud 169.254.3.93 -p 3922
<select id="country" name="country" class="full-width" selected="" data-init-plugin="select2">
<option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
@jampajeen
jampajeen / AND_OR_NOT
Created August 29, 2017 13:34 — forked from oliverdoetsch/AND_OR_NOT
Blogger: Globally conditional data tags for all page types
#AND
<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.searchQuery'>
<!--search_page AND index_page-->
</b:if>
</b:if>
#OR
@jampajeen
jampajeen / CSS3 Media Queries Template
Created April 9, 2018 18:55
CSS3 Media Queries template
/*
* Author: http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
@jampajeen
jampajeen / gist:e6ea1fa9583601921e2ef860d827370a
Created November 2, 2019 04:22
FIrebase facebook login button (custom button)
Button btnFacebook = findViewById(R.id.btn_facebook);
Drawable leftDrawable = AppCompatResources.getDrawable(this, R.drawable.baseline_power_settings_new_black_18dp);
btnFacebook.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, null, null);
// Start Facebook integration
LoginManager fbLoginManager = com.facebook.login.LoginManager.getInstance();
mCallbackManager = CallbackManager.Factory.create();
fbLoginManager.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
@jampajeen
jampajeen / nosleep.sh
Created November 27, 2019 14:42
Completely disable sleep on any Mac
# Useful to prevent Macbooks to go to sleep when closing the lid instead of running tools that requires a Kernel Extension (e.g. InsomniaX) and more
# Before doing anything, save your current configuration using
pmset -g
# To disable sleep
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1;
# And to go back to normal
sudo pmset -a sleep 1; sudo pmset -a hibernatemode [original hibernatemode value]; sudo pmset -a disablesleep 0;
@jampajeen
jampajeen / nesjs-typeorm-uuid-pk
Last active June 3, 2020 13:55
Nestjs TypeORM auto generate UUID as a primary key
@Entity()
export class User {
@PrimaryGeneratedColumn("uuid")
id: string;
}
@jampajeen
jampajeen / nestjs-mongoose-uuid
Created June 3, 2020 13:57
Nestjs mongoose use UUID as an id
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { v4 as uuidv4 } from 'uuid';
@Schema()
export class Course extends Document {
@Prop({ type: String, default: function genUUID() {
return uuidv4()
}})
@jampajeen
jampajeen / nats-cluster-healthcheck.yml
Created August 9, 2020 17:14
docker-compose nats steaming cluster healthcheck
healthcheck:
test: echo $$(wget --server-response http://node1:8222/varz 2>&1 | grep '200 OK') | grep '200' || exit 1
interval: 20s
timeout: 5s
retries: 5
start_period: 40s
@jampajeen
jampajeen / gist:d19f36a7309d0ead0e1f9735a26d66f3
Created January 12, 2021 15:35
Disable/Enable Mac OSX sleep on lid closed
# disable sleep
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1
# re-enable sleep
sudo pmset -b sleep 5; sudo pmset -b disablesleep 0