Skip to content

Instantly share code, notes, and snippets.

View petitJAM's full-sized avatar
🤖
beep boop Androids

Alex Petitjean petitJAM

🤖
beep boop Androids
View GitHub Profile
@petitJAM
petitJAM / get_firebase_project_names.js
Created March 29, 2019 18:26
Export all firebase project names
$('.c5e-project-card-project-name').map(function() { return $(this).text() }).toArray().join(", ")
@petitJAM
petitJAM / convert_mp4_to_gif.sh
Created February 28, 2019 19:09
Convert MP4 to GIF
ffmpeg -i file.mp4 -r 15 -vf scale=512:-1 file.gif
@petitJAM
petitJAM / collapse_junk_files_in_github_pr.js
Last active November 7, 2019 15:43
Bookmark JS for collapsing junk iOS files on GitHub PRs
/*
* Paste the following into a new bookmark, then click it on
* a GitHub PR to mark all the yucky Pod files as viewed.
*/
javascript:Array.from(document.querySelectorAll('a[title*=".xcodeproj"],a[title$=".storyboard"],a[title$=".pbxproj"],a[title^="Pods/"],a[title="Podfile.lock"]')).map(el => el.closest('.file-header').querySelector('.js-reviewed-checkbox')).forEach(function(el, i) { if (!el.checked) { el.click() } })
/*
* Readable version
*/
adb shell screencap -p /sdcard/screencap.png
adb pull /sdcard/screencap.png ./$1.png

Keybase proof

I hereby claim:

  • I am petitjam on github.
  • I am alex_p (https://keybase.io/alex_p) on keybase.
  • I have a public key ASA-IpgClDB6YWwt9nSIqekxoRiCDkOSNtZcKzoIbrwnnwo

To claim this, I am signing this object:

class SwipeRefreshAwareWebViewClient(private val swipeRefreshLayout: SwipeRefreshLayout)
: WebViewClient() {
override fun onReceivedHttpError(view: WebView?, request: WebResourceRequest?, errorResponse: WebResourceResponse?) {
Timber.d("errorResponse: %s", errorResponse?.data)
swipeRefreshLayout.isRefreshing = false
super.onReceivedHttpError(view, request, errorResponse)
}
override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
/**
* The [swipeRefreshLayout] will "steal" the swipe gesture from the [nestedWebView]
* when the user tries to scroll up on the web page. This class adds a
* [ViewTreeObserver.OnScrollChangedListener] to [swipeRefreshLayout] to disable
* refreshing while [nestedWebView] is not scrolled all the way to the top.
*/
class NestedWebViewScrollingSwipeRefreshLayoutFixer(
private val swipeRefreshLayout: SwipeRefreshLayout,
private val nestedWebView: WebView)
: LifecycleObserver {
@petitJAM
petitJAM / constants.coffee.erb
Created April 23, 2018 16:38
Ruby constants in JavaScript
window.ProjectName.SomeModel = {}
window.ProjectName.SomeModel.SomeConstants = {}
<% SomeModel::SomeConstants.constants.each do |constant| %>
window.ProjectName.SomeModel.SomeConstants.<%= constant %> = "<%= SomeModel::SomeConstants.const_get(constant) %>"
<% end %>
@petitJAM
petitJAM / ellipsized_text.xml
Last active March 24, 2021 08:04
Ellipsize TextView with 0dp in ConstraintLayout
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="4"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent"
@petitJAM
petitJAM / with_active_support.rb
Created March 20, 2018 22:07 — forked from mbyczkowski/with_active_support.rb
session cookie decrypter for Rails 4.2+
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]