javascript: (() => { Array.from(document.getElementsByTagName("relative-time")).forEach((d) => d.shadowRoot.textContent = d.title) })();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
osascript <<EOD | |
tell application "System Preferences" | |
(run) | |
set current pane to pane "com.apple.preference.trackpad" | |
end tell | |
tell application "System Events" | |
tell process "System Preferences" | |
delay 0.6 | |
click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad" |
-
New images for site / blog
- Reduce image size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# m h dom mon dow command | |
* * * * * /home/deepak/workspace/status_check.sh >> /home/deepak/workspace/logs/status.log 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hindi Voice Bot | |
* | |
* This function lets you ask questions in Hindi and get a proper response | |
*/ | |
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse() | |
if(event.SpeechResult) { | |
var got = require('got'); | |
var requestPayload = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/user.rb | |
class User < ActiveRecord::Base | |
has_many :posts, dependent: :destroy | |
has_many :published_posts, -> { published }, class_name: 'Post' | |
end | |
# app/models/post.rb | |
class Post < ActiveRecord::Base | |
belongs_to :user | |
scope :published, -> { where(published: true) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.includes(:published_posts).map do |user| | |
[user.name, user.published_posts.map(&:title).join(', ')] | |
end | |
User Load (0.3ms) SELECT "users".* FROM "users" | |
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE (published = 't') AND "posts"."user_id" IN (1, 2, 3) | |
#=> [["Jack", "post-1, post-2"], ["Adam", "post-3, post-3"], ["John", "post-5, post-6"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/user.rb | |
class User < ActiveRecord::Base | |
has_many :posts, dependent: :destroy | |
has_many :published_posts, -> { where(published: true) }, class_name: 'Post' | |
end | |
# app/models/post.rb | |
class Post < ActiveRecord::Base | |
belongs_to :user | |
scope :published, -> { where(published: true) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.includes(:posts).map do |user| | |
[user.name, user.posts.published.map(&:title).join(', ')] | |
end | |
User Load (0.2ms) SELECT "users".* FROM "users" | |
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1, 2, 3) | |
Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ? AND "posts"."published" = 't' [["user_id", 1]] | |
Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ? AND "posts"."published" = 't' [["user_id", 2]] | |
Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ? AND "posts"."published" = 't' [["user_id", 3]] | |
#=> [["Jack", "post-1, post-2"], ["Adam", "post-3, post-3"], ["John", "post-5, post-6"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.includes(:posts).map do |user| | |
[user.name, user.posts.map(&:title).join(', ')] | |
end | |
User Load (0.2ms) SELECT "users".* FROM "users" | |
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1, 2, 3) | |
#=> [["Jack", "post-1, post-2"], ["Adam", "post-3, post-3"], ["John", "post-5, post-6"]] |
NewerOlder