Skip to content

Instantly share code, notes, and snippets.

@miketartar
Created September 26, 2020 04:21
Show Gist options
  • Save miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775 to your computer and use it in GitHub Desktop.
Save miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775 to your computer and use it in GitHub Desktop.
Cold Turkey Blocker Activator
import json
import sqlite3
import os
DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"
def activate():
try:
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
s = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(s)
if dat["additional"]["proStatus"] != "pro":
print("Your version of Cold Turkey Blocker is not activated.")
dat["additional"]["proStatus"] = "pro"
print("But now it is activated.\nPlease close Cold Turkey Blocker and run again it.")
c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
conn.commit()
else:
print("Looks like your copy of Cold Turkey Blocker is already activated.")
print("Deactivating it now.")
dat["additional"]["proStatus"] = "free"
c.execute("""UPDATE settings set value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
conn.commit()
except sqlite3.Error as e:
print("Failed to activate", e)
finally:
if conn:
conn.close()
def main():
if os.path.exists(DB_PATH):
print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
activate()
else:
print("Looks like Cold Turkey Blocker is not installed.\n If it is installed then run it at least once.")
if __name__ == '__main__':
main()
@safia-nusrat-official
Copy link

to which dir we have to open cmd? "C:/ProgramData/Cold Turkey/data-app.db" this?

@matke203
Copy link

i don't know if i'm stupid or what but I can't seem to run the code, i'm getting indentation errors, syntax errors, cold turkey is not installed etc.
this is my first time using python and I watched a few youtube videos and tried some stuff but just can't run the code

@matke203
Copy link

i don't know if i'm stupid or what but I can't seem to run the code, i'm getting indentation errors, syntax errors, cold turkey is not installed etc. this is my first time using python and I watched a few youtube videos and tried some stuff but just can't run the code

okay I somehow got it to work idk how, thank you very much

@Stiven106
Copy link

You're a genius man, thanks!

@claudiaclaudiaclaudia
Copy link

Thank you so much, now I can schedule my blocks on Cold Turkey!

@PratikDahal-01
Copy link

Working Thanks Mate

@lisan-al-ghaib
Copy link

lisan-al-ghaib commented Oct 2, 2024

I ran the code and checked to see that ProStatus is set to pro, but it still isnt activated for some reason. Any idea what the issue could be? tries it on version 4.3 btw

@Serminx
Copy link

Serminx commented Oct 9, 2024

I ran the code but it still isnt activated for some reason, my mistake for sure
edit: it works thank you so muchh, I really need this

@jalalcool12345
Copy link

I ran the code but it still isnt activated for some reason, my mistake for sure edit: it works thank you so muchh, I really need this

can u pls help me it doesnt work. i put the python in the directory and i opened the cmd in the directorry and i pasted the code in the cmd. but it stil ldoesnt work

@1qwerty-qwerty124
Copy link

1qwerty-qwerty124 commented Nov 23, 2024

The mac version is below.

How to use:

  1. Go to Allow in Background and turn off Felix Belzile.
  2. Press option+command+esc to quit Cold Turkey Blocker.
  3. Open TextEdit and create a new file named ColdTurkeyBlockerActivator.py (save it as .txt first, then rename it to .py).
  4. Paste cd ~/Documents in Terminal and press Enter.
  5. Run the script with sudo python3 ColdTurkeyBlockerActivator.py and enter your password when prompted.
  6. Enjoy your activated Cold Turkey Blocker!
import json
import sqlite3
import os

DB_PATH = "/Library/Application Support/Cold Turkey/data-app.db"

def activate():
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        s = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
        dat = json.loads(s)

        if dat["additional"]["proStatus"] != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            dat["additional"]["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run again it.")
            c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
            conn.commit()
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            dat["additional"]["proStatus"] = "free"
            c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
            conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed then run it at least once.")

if __name__ == '__main__':
    main()

@Kiwan28
Copy link

Kiwan28 commented Dec 11, 2024

Hey, I'm on windows 10 and this code doesn't seem to work no matter how many times I try.
Funny thing is it used to run on my old laptop, but I'm making a mistake God knows where that is leaving me empty-handed.
Can someone please help?
Thank you!

@oednsk
Copy link

oednsk commented Dec 16, 2024

what is this please help me

cd: not a directory: /Users/augustin/Documents/ColdTurkeyBlockerActivator.py
augustin@MacBook-Air-de-augustin Documents %

it the Paste cd ~/Documents in Terminal and press Enter.
Run the script with sudo python3 ColdTurkeyBlockerActivator.py and enter your password when prompted.
Enjoy your activated Cold Turkey Blocker!
of the things below

@SwiftWinds
Copy link

SwiftWinds commented Dec 21, 2024

The mac version is below.

How to use:

  1. Go to Allow in Background and turn off Felix Belzile.
  2. Press option+command+esc to quit Cold Turkey Blocker.
  3. Open TextEdit and create a new file named ColdTurkeyBlockerActivator.py (save it as .txt first, then rename it to .py).
  4. Paste cd ~/Documents in Terminal and press Enter.
  5. Run the script with sudo python3 ColdTurkeyBlockerActivator.py and enter your password when prompted.
  6. Enjoy your activated Cold Turkey Blocker!
import json
import sqlite3
import os

DB_PATH = "/Library/Application Support/Cold Turkey/data-app.db"

def activate():
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        s = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
        dat = json.loads(s)

        if dat["additional"]["proStatus"] != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            dat["additional"]["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run again it.")
            c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
            conn.commit()
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            dat["additional"]["proStatus"] = "free"
            c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
            conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed then run it at least once.")

if __name__ == '__main__':
    main()

Thank you so much! ❤️ it works on the latest version :)

@1qwerty-qwerty124
Copy link

1qwerty-qwerty124 commented Dec 22, 2024 via email

@username56432
Copy link

@Voyrox, thank you brother!!

@Voyrox
Copy link

Voyrox commented Jan 9, 2025

Anytime!

@JustaTurtle21
Copy link

this is the more updated version:

import json
import sqlite3
import os

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def activate():
    conn = None  # Initialize conn to None to handle exceptions during connection
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        
        # Fetch settings
        result = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()
        if not result:
            print("No settings found in the database.")
            return
        
        s = result[0]
        dat = json.loads(s)
        
        # Check and update proStatus
        additional = dat.setdefault("additional", {})  # Safely get 'additional' key
        if additional.get("proStatus") != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            additional["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run it again.")
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            additional["proStatus"] = "free"
        
        # Update the database
        c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (json.dumps(dat),))
        conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate:", e)
    except json.JSONDecodeError as e:
        print("Failed to parse settings JSON:", e)
    except KeyError as e:
        print("Key error in settings data:", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed, please run it at least once.")

if __name__ == '__main__':
    main()

has worked for cold turkey 4.5

@zrhzrhz
Copy link

zrhzrhz commented Feb 26, 2025

this is the more updated version:

import json
import sqlite3
import os

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def activate():
    conn = None  # Initialize conn to None to handle exceptions during connection
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        
        # Fetch settings
        result = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()
        if not result:
            print("No settings found in the database.")
            return
        
        s = result[0]
        dat = json.loads(s)
        
        # Check and update proStatus
        additional = dat.setdefault("additional", {})  # Safely get 'additional' key
        if additional.get("proStatus") != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            additional["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run it again.")
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            additional["proStatus"] = "free"
        
        # Update the database
        c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (json.dumps(dat),))
        conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate:", e)
    except json.JSONDecodeError as e:
        print("Failed to parse settings JSON:", e)
    except KeyError as e:
        print("Key error in settings data:", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed, please run it at least once.")

if __name__ == '__main__':
    main()

has worked for cold turkey 4.5

thanks a lot man, can you make a similar script for cold turky Micromanager as well?

@Kuchi-Rahul
Copy link

Wo

this is the more updated version:

import json
import sqlite3
import os

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def activate():
    conn = None  # Initialize conn to None to handle exceptions during connection
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        
        # Fetch settings
        result = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()
        if not result:
            print("No settings found in the database.")
            return
        
        s = result[0]
        dat = json.loads(s)
        
        # Check and update proStatus
        additional = dat.setdefault("additional", {})  # Safely get 'additional' key
        if additional.get("proStatus") != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            additional["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run it again.")
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            additional["proStatus"] = "free"
        
        # Update the database
        c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (json.dumps(dat),))
        conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate:", e)
    except json.JSONDecodeError as e:
        print("Failed to parse settings JSON:", e)
    except KeyError as e:
        print("Key error in settings data:", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed, please run it at least once.")

if __name__ == '__main__':
    main()

has worked for cold turkey 4.5

thanks a lot man, can you make a similar script for cold turky Micromanager as well?

Worked bro

@Jaat2727
Copy link

Bruh serious this is dope shit, worked for me

@ayyyuuuuuuuub
Copy link

this is the more updated version:

import json
import sqlite3
import os

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def activate():
    conn = None  # Initialize conn to None to handle exceptions during connection
    try:
        conn = sqlite3.connect(DB_PATH)
        c = conn.cursor()
        
        # Fetch settings
        result = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()
        if not result:
            print("No settings found in the database.")
            return
        
        s = result[0]
        dat = json.loads(s)
        
        # Check and update proStatus
        additional = dat.setdefault("additional", {})  # Safely get 'additional' key
        if additional.get("proStatus") != "pro":
            print("Your version of Cold Turkey Blocker is not activated.")
            additional["proStatus"] = "pro"
            print("But now it is activated.\nPlease close Cold Turkey Blocker and run it again.")
        else:
            print("Looks like your copy of Cold Turkey Blocker is already activated.")
            print("Deactivating it now.")
            additional["proStatus"] = "free"
        
        # Update the database
        c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (json.dumps(dat),))
        conn.commit()

    except sqlite3.Error as e:
        print("Failed to activate:", e)
    except json.JSONDecodeError as e:
        print("Failed to parse settings JSON:", e)
    except KeyError as e:
        print("Key error in settings data:", e)
    finally:
        if conn:
            conn.close()

def main():
    if os.path.exists(DB_PATH):
        print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
        activate()
    else:
        print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed, please run it at least once.")

if __name__ == '__main__':
    main()

has worked for cold turkey 4.5

still works

@SobhnathxLuffy
Copy link

SobhnathxLuffy commented Mar 30, 2025

i have a problem i dont have a file named "data-app.db". it gives "Looks like Cold Turkey Blocker is not installed.
If it is installed, please run it at least once" .my installation folder looks like this.--
image
image

@PratikDahal-01
Copy link

PratikDahal-01 commented Apr 1, 2025

i have a problem i dont have a file named "data-app.db".
@SobhnathxLuffy

You are on the wrong path (The file is hidden) access it by enabling show hidden files in C folder or enter this path:
C:\ProgramData\Cold Turkey

@Juancho2004gg
Copy link

I ran it and the app is still on the free version.

@nguyenhungphongg
Copy link

nguyenhungphongg commented Apr 13, 2025

I ran it and the app is still on the free version.

Run the code of JustaTurtle21. Its worked for me

@ace9804
Copy link

ace9804 commented Apr 14, 2025

I ran it and the app is still on the free version.

Run the code of SobhnathxLuffy. Its worked for me

bro its not working for 4.6
any tips you can provide?

@SobhnathxLuffy
Copy link

i have a problem i dont have a file named "data-app.db".
@SobhnathxLuffy

You are on the wrong path (The file is hidden) access it by enabling show hidden files in C folder or enter this path: C:\ProgramData\Cold Turkey

THANKS ALOT BRO ! IT WORKED.

@nguyenhungphongg
Copy link

nguyenhungphongg commented Apr 15, 2025

I ran it and the app is still on the free version.

Run the code of SobhnathxLuffy. Its worked for me

bro its not working for 4.6 any tips you can provide?

I'm on 4.6 version and this worked for me. Try the code JustaTurtle21 just updated above, https://gist.github.com/miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775?permalink_comment_id=5426749#gistcomment-5426749.
Just download python, set up the environment, create a file name.txt, and open CMD, type "python name.txt" and it should be worked.
Screenshot 2025-04-15 182327

@ace9804
Copy link

ace9804 commented Apr 17, 2025

I ran it and the app is still on the free version.

Run the code of SobhnathxLuffy. Its worked for me

bro its not working for 4.6 any tips you can provide?

I'm on 4.6 version and this worked for me. Try the code JustaTurtle21 just updated above, https://gist.github.com/miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775?permalink_comment_id=5426749#gistcomment-5426749. Just download python, set up the environment, create a file name.txt, and open CMD, type "python name.txt" and it should be worked. Screenshot 2025-04-15 182327

thanks mate for the reply
however i already tried JustaTurtle21's approach again and it worked seamlessly

@JustaTurtle21
Copy link

JustaTurtle21 commented Apr 17, 2025

also sorry to all the fellows who have been asking me stuff, I was quite busy and cant really help anymore as I am on linux, I sincerely apologize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment